Express Response Methods

About This Index
This page is the Express Response index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
In every route handler, Express passes (req, res). Use this page when you need to finish a request with res.send(), res.json(), or res.status().
Start with res.send() and res.json(), then res.status()—add res.redirect() and res.render() when you need navigation or templates.
How to Call a Response Method
Chain status and headers, then send exactly one body (or redirect/render):
app.get("/", (req, res) => {
res.send("Hello Express");
});
app.get("/api/user", (req, res) => {
res.status(200).json({ id: 1, name: "Ada" });
});
app.post("/login", (req, res) => {
res.cookie("sid", "abc", { httpOnly: true });
res.redirect("/dashboard");
});
app.get("/about", (req, res) => {
res.render("about", { title: "About" });
}); Express Response Methods Table
All Response property and method guides in this Express.js tutorial series (24 tutorials).
Sending a Body
6 methodsFinish the response — send, JSON, JSONP, end, status-only, and format.
| Method | Description | Tutorial |
|---|---|---|
res.send() | Send a response body — strings, Buffers, objects, or arrays. | Try it |
res.json() | Send a JSON response — sets Content-Type and serializes the value. | Try it |
res.jsonp() | Send a JSONP response with an optional callback query parameter. | Try it |
res.end() | End the response process without sending more body data. | Try it |
res.sendStatus() | Set the status code and send its string name as the body. | Try it |
res.format() | Content negotiation — respond differently per Accept type. | Try it |
Status & Headers
8 methodsSet status codes and response headers before the body is sent.
| Method | Description | Tutorial |
|---|---|---|
res.status() | Set the HTTP status code and chain another response method. | Try it |
res.set() | Set one or more response headers (alias: res.header). | Try it |
res.get() | Read a response header that was already set on res. | Try it |
res.type() | Set the Content-Type from a MIME string or file extension. | Try it |
res.append() | Append a value to a response header (multi-value headers). | Try it |
res.vary() | Add a field to the Vary response header for caches. | Try it |
res.links() | Populate the Link header with relation URLs. | Try it |
res.headersSent | Boolean — true after response headers have been written. | Try it |
Redirects
2 methodsSend the client to another URL with Location / redirect helpers.
| Method | Description | Tutorial |
|---|---|---|
res.redirect() | Redirect the client to a URL with an optional status code. | Try it |
res.location() | Set the Location header without ending the response. | Try it |
Files & Downloads
3 methodsStream files from disk or force a download dialog.
| Method | Description | Tutorial |
|---|---|---|
res.sendFile() | Transfer a file from disk as the response body. | Try it |
res.download() | Prompt a file download with Content-Disposition attachment. | Try it |
res.attachment() | Set Content-Disposition to attachment — optionally with a filename. | Try it |
Views
2 methodsRender templates and pass request-scoped locals.
| Method | Description | Tutorial |
|---|---|---|
res.render() | Render a view template and send the HTML as the response. | Try it |
res.locals | Request-scoped variables available to templates during render. | Try it |
App Link
1 methodReach the owning Express application from res.
Frequently Asked Questions
Start with res.send()
Open the send guide—syntax, examples, and FAQs.
CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
16 people found this page helpful
