@grpc/grpc-js: ^1.3.3 Node.js: v14.17.3
Client.js
client.updateBillingItems(request, function(err, response) {
if (err) {
res.send({error:'Server failed to update billing item'});
}
else {
res.send(response);
}
});
backend.js
PCServiceImpl.prototype.updateBillingItems = function updateBillingItems(call, callback) {
var billingitems = call.request.billingitems; //Here the request received ( request: { billingitems: [] } ) is empty although data is passed from the client. Hence the susequent code fails to execute.
console.log('updateBillingItems:', billingitems)
es_query_obj.es_update_billing_items(billingitems)
.then( results => {
console.log('updateBillingItems:', JSON.stringify(results));
callback(null, results);
})
.catch(err => {
console.error("updateBillingItems: Caught ES exception:", err)
callback(err)
});
}
request: { billingitems: [] } -> billingitems must be an array as below
[{"chargemonth":"2021-12","dateofservice":"2021-12-20","geo":"LA"}]
So whenever updateBillingItems() is called by the client.js, it tries to send the updated data in the form of array to backend service, but the the request received by backend service is empty, not sure why. My code uses proto as well, request and response format are according to the proto definitions, but still this call fails.