Difference between response.status() vs. response.sendStatus() in express

status() sets a HTTP status on the response (as a Javascript object on the server side).

sendStatus() sets the status and sends it to the client.

The usage doesn’t depend on the HTTP method of the request. In most cases you would use sendStatus anyway since it’s unlikely that the status changes once the request is processed (especially since status code is the first line in a raw HTTP response).

Read more in the docs:

https://expressjs.com/en/4x/api.html#res.sendStatus

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)