jelpi
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v66View latest version
| title: | Basic examples |
|---|---|
| description: | Examples of basic HTTP triggers for common use cases |
import Val from "@components/Val.astro";
HTTP triggers expose a public endpoint.
The simplest endpoint returns a simple JSON message:
Or you could return HTML with the corresponding Content-Type header:
This echoes request headers back in the response:
We can get and return the request URL's query parameters:
You can also get the body of POST requests:
To obtain the HTTP endpoint, use the "Copy HTTP endpoint" button in the ... menu.