Kellen Mace
03/16/2022, 4:22 AMts
export async function post(event: RequestEvent): Promise<RequestHandlerOutput> {
console.log(event.request.url);
}
Example:
If the request is sent to http://localhost:3000/api/my-endpoint?test=abc123
, I want to access the value of test
, which would be abc123
.
Thanks for any help you can give!Needle
03/16/2022, 4:22 AM/title
command!
We have solved your problem?
Click the button below to archive it.lawrencecchen
03/16/2022, 4:24 AMjs
export async function post({ request }) {
so you can get the search params from the request like so:
javascript
const url = new URL(request.url);
const search = url.searchParams.get("test");
Needle
03/16/2022, 4:24 AMlawrencecchen
03/16/2022, 4:26 AMKellen Mace
03/16/2022, 4:27 AMKellen Mace
03/16/2022, 4:28 AMRequest
and I'm familiar with URLSearchParams
too, but not instantiating URL
, like you didKellen Mace
03/16/2022, 4:28 AM