How to get a request query from an api route #662
Replies: 1 comment 1 reply
// routes/api/wrap.ts
import { Handlers } from "$fresh/server.ts";
export const handler: Handlers = {
async GET(req, ctx) {
const url = new URL(req.url);
const action = url.searchParams.get("action");
if (!action) return new Response("Bad Request", { status: 400 });
return Response.json({ action });
},
}; |
1 reply
Answer selected by
waptik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi. I'm trying to get the query from an api route.
Eg:
http://localhost:8000/api/wrap?action=infoI can't seem to find any object to from
reqorctxto get theactionquery and it's value.All reactions