reply.send()
Sends the response payload, serializing objects to JSON by default.
Syntax
reply.send(payload?: any) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
payload | any | No | An object, string, Buffer, stream, or Error to send. |
Returns
FastifyReply — The reply, for chaining.
Examples
import Fastify from 'fastify';
const app = Fastify();
app.get('/explicit', (req, reply) => {
reply.code(200).send({ ok: true });
});
app.get('/return', async () => ({ ok: true }));
Notes
In async handlers, returning a value is equivalent to calling send().
Call send() explicitly in callback-style handlers. Sending an Error
routes to the error handler.