Why is a Javascript Error object not treated as an object by expressjs -
i have node/express backend. in backend create error object if there error, when try send in response not there. able make code work building new object in response, know why didn't work.
the relevant code is:
var error = new error('some error message') app.send({error}) // returns {} app.send({error: error.message}) // returns {error: 'some error message}
according mdn docs, error object object, , should therefore able pass directly app.send(). didn't work in practice, , able explain why. help!
i assume app.send
converts value json. json.stringify
considers (own) enumerable properties , message
not enumerable:
> object.getownpropertydescriptor(new error('foo'), 'message'); object {value: "foo", writable: true, enumerable: false, configurable: true}
Comments
Post a Comment