query
Introduction
The query function is just a helper function to help extract query parameters from URLs. It uses the WHATWG URL API under the hood to extract the query parameters and convert it from a URLSearchParams to a JSON object.
If there are multiple query parameters with the same name, it will return an array instead of a string.
Usage
Simply call the query function inside of your handler.
After starting the dev server, you can make a request to localhost:3000/?id=123&name=light and expect a response of
Note that by default all query parameters are strings, and you will need to cast them as necessary.
Last updated