When updating data partially, data does not persist. For example, I call the following (where data is an object):
account.updateAttributes(data).then(function(updated) {
res.send(updated);
return next();
})['catch'](function(err) {
log.error(err);
return next(new restify.InternalError(err.message));
});
I guess you want to pass updated data to next middleware. But you used res.send(updated). It terminates middleware and return the response.
You can use to pass the updated data with the following;
account.updateAttributes(data).then(function(updated) {
req.updatedAccount = updated;
return next();
})['catch'](function(err) {
log.error(err);
return next(new restify.InternalError(err.message));
});
So you can attach the updated data to your request object and send with it to next middleware. And you can use the data in next middleware with req.updatedAccount.
I hope it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With