how to get all query strings array in +server.js ? #8634
Answered
by
eltigerchino
magic-thomas
asked this question in
Q&A
-
in './src/routes/api/videos/+server.js ' /** @type {import('./$types').RequestHandler} */
export async function GET( { request, response }) {
console.log(request.url.searchParams.get('video_key') )
} I access this url But it give me error TypeError: Cannot read properties of undefined (reading 'get') How can I get all query string arrays in +server.js ? |
Beta Was this translation helpful? Give feedback.
Answered by
eltigerchino
Jan 21, 2023
Replies: 1 comment
-
The official https://developer.mozilla.org/en-US/docs/Web/API/Request/url However, you can access the /** @type {import('./$types').RequestHandler} */
- export async function GET( { request, response }) {
+ export async function GET( { url }) {
- console.log(request.url.searchParams.get('video_key') )
+ console.log(url.searchParams.get('video_key') )
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
magic-thomas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The official
Request
interface only providesrequest.url
as a string.https://developer.mozilla.org/en-US/docs/Web/API/Request/url
However, you can access the
URL
interface from the arguments instead such as