reply.status()
Sets the HTTP status code for the response (alias of reply.code()).
Syntax
reply.status(statusCode: number) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
statusCode | number | No | The HTTP status code to send. |
Returns
FastifyReply — The reply, for chaining.
Examples
import Fastify from 'fastify';
const app = Fastify();
app.delete('/cats/:id', async (req, reply) => {
return reply.status(204).send();
});
Notes
status() is a direct alias of code(); use whichever reads better. It
must be set before the body is sent.