-
SummaryIm creating a serverless function and Im trying to use the query helper function but if I try to print request.query it prints undefined and I can see "Property 'query' does not exist on type 'Request'." My function looks like this:
and already ran npm install @vercel/node --save-dev am I missing an import or something like that? ExampleNo response Steps to Reproduce1.- Create a serverless function with node. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The I'm assuming you want to access the query parameters of the request. You can do so by accessing the export async function GET(request: Request) {
const url = new URL(request.url)
const query = url.searchParams
// query is a URLSearchParams object: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
} |
Beta Was this translation helpful? Give feedback.
-
Understand that but I expected to find the .query from Vercel helpers https://vercel.com/blog/vercel-node-helpers |
Beta Was this translation helpful? Give feedback.
The
query
property indeed doesn't exist on theRequest
object: https://developer.mozilla.org/en-US/docs/Web/API/RequestI'm assuming you want to access the query parameters of the request. You can do so by accessing the
url
property, constructing a newURL
object and accessing thesearchParams
property: