I have inherited some very messy loopback code and I want to know if it is possible to return a status code other than 200.
For example I have the following code:
PensionsUser.loginView = function (ctx, credentials, cb) {
var respJSON = util.getresponseTemplate();
credentials.email = credentials.email.toLowerCase().trim();
PensionsUser.login(credentials, 'user', function (err, loginResp) {
if (err) {
util.addErrorToResponse(err, respJSON, 'NO-PUS-LV-001');
app.log.error(util.loggingTemplate('PensionsUser', 'loginView', 'NO-PUS-LV-001', credentials.email));
ctx.res.status = 401; //does not work
cb(null, respJSON);
//etc.
I know cb(null, respJSON)
should be returning the error like this cb(respJSON)
but sadly the frontend code relies on this JSON being returned as currently is so my first step would be to just change the status code.
Is this possible?