Nuxt/docs/content/3.api/3.utils/set-response-status.md
Yaël Guilloux dc47c64f14
docs: use nuxt 3 and website theme (#5479)
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: pooya parsa <pyapar@gmail.com>
Co-authored-by: Clément Ollivier <clement.o2p@gmail.com>
2022-10-06 11:15:30 +02:00

23 lines
661 B
Markdown

---
description: setResponseStatus sets the statusCode (and optionally the statusMessage) of the response.
---
# `setResponseStatus`
Nuxt provides composables and utilities for first-class server-side-rendering support.
`setResponseStatus` sets the statusCode (and optionally the statusMessage) of the response.
`setResponseStatus` can only be called within component setup functions, plugins, and route middleware.
```js
// Set the status code to 404 for a custom 404 page
setResponseStatus(404)
// Set the status message as well
setResponseStatus(404, 'Page Not Found')
```
::alert{icon=👉}
In the browser, `setResponseStatus` will have no effect.
::