kissa
kissa
SSolidJS
Created by kissa on 9/5/2024 in #support
Best way to get search params in an API route?
Since useSearchParams() doesn't work in API routes, I'm wondering if there's an easier way to get them than what I came up with:
export async function GET({ request }: APIEvent) {
let searchParams = Object.fromEntries(
new URL(request.url).searchParams.entries()
)
export async function GET({ request }: APIEvent) {
let searchParams = Object.fromEntries(
new URL(request.url).searchParams.entries()
)
which seems a bit cumbersome. I'm passing the params to zod so I'll need them in plain object format.
4 replies