Need to pass query params #1066
RathodSanjayL
started this conversation in
General
Replies: 1 comment 10 replies
-
Hi @RathodSanjayL! If you want access your query parameters, pass a proper relative testApiHandler({
appHandler: {
async GET(request) {
console.log(request.nextUrl);
return Response.json(
{ queryString: request.nextUrl.search },
{ status: 200 }
);
}
},
// Note how the URL begins with a "/" and does not require a path
url: '/?page=1&page_size=10', // <== These appear in request.nextUrl.searchParams
test: async ({ fetch }) => {
const res = await fetch({ method: 'GET' });
await expect(res.json()).resolves.toStrictEqual({
queryString: '?page=1&page_size=10'
});
}
}); |
Beta Was this translation helpful? Give feedback.
10 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I need to pass query parameters along with the URL to get API for pagination.
In the App Router API folder I have one API
api/users?page=1&page_size=10
.how I can pass this page and page_size query params.
I tried with this where I am passing URL like
api/users?page=1&page_size=10
please help me how to get rid of this issue
Beta Was this translation helpful? Give feedback.
All reactions