json

json is a helper function to send JSON HTTP Responses.
tsx
const response = json({ hello: "world" });
tsx
const response = json({ hello: "world" });


Usage

json is a helper for sending responses with content-type application/json.

It is useful for sending JSON responses from API Routes.

tsx
import { json } from "solid-start";
 
export function GET() {
return json({ hello: "world" });
}
tsx
import { json } from "solid-start";
 
export function GET() {
return json({ hello: "world" });
}

Reference

json(data: any)

Use json() to create a Response by serializing a JSON object. It will set the content-type to application/json. Basically wherever a Response is expected, it is useful inside.

For example:

ts
import { json } from "solid-start";
 
const response = json({ hello: "world" });
ts
import { json } from "solid-start";
 
const response = json({ hello: "world" });