json
A JSON response.
A JSON response. The body is serialized with JSON.stringify; Content-Type is
application/json; charset=utf-8 and sniffing is disabled.
Import#
ts
import { json } from "@shadow-js/dusk/server";
Signature#
ts
function json(data: unknown, init: ResponseInit = {}): Response
Parameters#
| Name | Description |
|---|---|
data |
Any JSON-serializable value. |
init |
Status and headers. |
Returns#
The response.
Throws#
- TypeError when
datacannot be serialized (cycles, BigInt).
Examples#
ts
export const GET = () => json({ ok: true }, { status: 200 });