GET
Edit this pageGET
helps to create a server function which is accessed via an HTTP GET request.
When this function is called, arguments are serialized into the URL, thus allowing the use of HTTP cache-control headers.
For example, GET
can be used to make a streaming promise with a 60 second cache life:
import { json } from "@solidjs/router";import { GET } from "@solidjs/start";
const hello = GET(async (name: string) => { "use server"; return json( { hello: new Promise<string>((r) => setTimeout(() => r(name), 1000)) }, { headers: { "cache-control": "max-age=60" } } );});
Parameters
GET<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>