The res object represents the HTTP response your Express server sends back. Express supports method chaining so you can set a status code and send a payload in one clean statement.
Common Response Methods
res.send()— Sends strings, HTML, Buffers, or objects (auto-setsContent-Type).res.json()— Explicitly serializes data as JSON withapplication/jsonheader.res.status(code)— Sets the HTTP status code before sending.res.sendStatus(code)— Sets status and sends its standard text message (e.g.,204 No Content).
ADVERTISEMENT