Setting up HTTP status code

If you remember, HTTP statuses let you give someone some information about how the request went. Did it go well? Did it go poorly? That kind of thing. You can get a list of all the HTTP statuses available to you by going to httpstatuses.com. Here, you can view all of the statuses that you can set:

The one that's set by default by Express is 200. This means that things went OK. What we're going to be using for an error is code 400. A 400 status means there was some bad input, which is going to be the case if the model can't be saved. Maybe the User didn't provide a text property, or maybe the text string was empty. ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.