You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using node I make a typical API POST request for which I have a .catch block with response variable say err. On error, the response body is returned as such (as seen from the Hyperledger Composer REST app)
{
"error": {
"statusCode": 500,
"name": "Error",
"message": "error trying invoke chaincode. Error: chaincode error (status: 500, message: Error: Payment needs to be of positive value)",
"stack": "Error: error trying invoke chaincode. Error: chaincode error (status: 500, message: Error: Payment needs to be of positive value)\n at _initializeChannel.then.then.then.then.catch (/home/ubuntu/.nvm/versions/node/v6.11.1/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:839:34)"
}
}
My Issue
I am simply trying to fetch the message property from the above response and send it to the UI. But weirdly err.messagedoes not give me the value I see inside message but returns the entire response body(same with err.stack).
So basically -- err, err.message and err.stack returns the same output
How do I end up fetching only the value inside a property say message ?
PS: err.statusCode does return the correct value ie. "500". err.name returns "StatusCodeError"(not "Error" that I see in the response)
Description
Using node I make a typical API POST request for which I have a
.catchblock with response variable sayerr. On error, the response body is returned as such (as seen from the Hyperledger Composer REST app)My Issue
I am simply trying to fetch the
messageproperty from the above response and send it to the UI. But weirdlyerr.messagedoes not give me the value I see insidemessagebut returns the entire response body(same witherr.stack).So basically --
err,err.messageanderr.stackreturns the same outputHow do I end up fetching only the value inside a property say
message?PS:
err.statusCodedoes return the correct value ie. "500".err.namereturns "StatusCodeError"(not "Error" that I see in the response)