Readme

Handling query params in requests

Using the standard URL#searchParams method, you can grab query parameters out of any val that is operating using the Web API.

This val demonstrates how to grab one or more query parameters. It returns the all the query parameters found as a json response.

1
2
3
4
export const queryParams = (req: Request) => {
const searchParams = new URL(req.url).searchParams;
return Response.json(Object.fromEntries(searchParams.entries()));
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.