Tuesday, 23 May 2017

Node.js break promise chain

I am trying to break the promise chain by not returning a promise at one of the intermediary steps.

identity
.token(username, password)
})
.then((response) => {
  // Here I would like to break the promise chain.. HELP please..
  if (!token.tfa || !allow2FA)
    return res.status(200).json(token.raw);

  return twoFactor.generateLoginOtc(username, token);
})
.then((response) => {
  return res.status(204).json();
})
.catch((error) => {
  console.log(error);
  return res.status(error.status).json(error);
});



via Gabriel

No comments:

Post a Comment