1

Going through all of the tutorials of DietJS here: Diet.js | Tutorials, I am not able to find a way to respond with a particular response code.

In the signals section, it is mentioned that we can use:

$.failure();

And we can put in more information about the failure through:

$.error("username", "missing");

But it responds with code 200 by default. There are no direct pointers towards setting up the desired response code.

Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55

1 Answers1

1

After wasting a lot of time I figured out that you can actually do:

$.status(401, "Bad Request");

before you end the request with $.end(), $.failure() or any other alternatives.

Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55