Skip to content
Myr

docs for res.json

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 1386f80 · Browse files · 1 file+12 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−0 removed

  • other:+12 added−0 removed

1 file+12 added−0 removed

modified:docs/guide.md+12 added
913 unmodified lines
914it will not be set again.915916Note that this method _end()_s the response, so you will want to use node's _res.write()_ for multiple writes or streaming.917918### res.json(obj[, headers|status[, status]])919920 Send a JSON response with optional _headers_ and _status_. This method921 is ideal for JSON-only APIs, however _res.send(obj)_ will send JSON as922 well, though not ideal for cases when you want to send for example a string923 as JSON, since the default for _res.send(string)_ is text/html.924925 res.json(null);926 res.json({ user: 'tj' });927 res.json('oh noes!', 500);928 res.json('I dont have that', 404);929930### res.redirect(url[, status])931932Redirect to the given _url_ with a default response _status_ of 302.933
473 unmodified lines