Languages

Node.js - how to use res.send() with res.sendStatus()?

0 points
Asked by:
FryerTuck
649

How can I use res.send() method with res.sendStatus() at once to send status code and object with message at once?

1 answer
0 points
Answered by:
Admin Dirask Community
4380

You can chain it together using one method after the other with dot (.) separator.

Quick solution:

Practical example

This example presents HTTP GET request that returns all users from a database with status 200 and object with some message at once.

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join