I'm programming a reset password system in nodejs JWT. In some functions I dont't really need to send nothing as answer to the frontend, just is important the HTTP Status Code.. But i'm not sure if it's a good practice returning a null value.
CodePudding user response:
Sure, that could work if the status code is the only information you need to convey in the request. There's even an Express method designed for exactly this - to send the status code (and in the body the corresponding message for the code, just in case it's useful, though you're free to ignore it). See res.sendStatus
. sendStatus
would be a bit more appropriate than .send(null)
though.
CodePudding user response:
you can use status code 204
instead
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/204