2xx Success
HTTP 204 No Content
HTTP 204 No Content means the request succeeded and there is deliberately no response body.
What 204 No Content means
A 204 is a good answer to DELETE, to a PUT or PATCH where the client already has the new state, and to CORS preflight requests. Any body sent with a 204 is ignored, and Angular HttpClient returns null for it.
Common causes
- A DELETE removed a resource.
- An update succeeded and the server returns nothing.
- A CORS preflight (OPTIONS) was accepted.
How to fix or use it
Do not call res.json() with a 204: use res.sendStatus(204) or res.status(204).end(). If the client needs the updated object, return 200 with it instead.
Express (Node.js) example
app.delete('/api/posts/:id', async (req, res) => {
await Post.deleteOne({ _id: req.params.id });
res.sendStatus(204);
});SEO impact
A page URL that answers 204 has no content to index. Keep 204 for API endpoints, never for HTML pages.
