How to find rendered URL #1809
-
What would you like to discuss?How can I find out the rendered URL with all searchParams etc? I'm having some issues where I expect the searchParams being wrongly encoded and would like to verify that by seeing what's actually being sent... ... Checklist
|
Beta Was this translation helpful? Give feedback.
Answered by
sindresorhus
Oct 11, 2025
Replies: 1 comment
-
|
you can get the rendered URL in a few ways: after the request completes: const response = await got('https://example.com', {
searchParams: {foo: 'bar', baz: 'qux'}
});
console.log(response.requestUrl.toString());
// => https://example.com?foo=bar&baz=qux
console.log(response.url);
// => final URL as string (after redirects)before the request is sent (to debug encoding): await got('https://example.com', {
searchParams: {foo: 'bar baz'},
hooks: {
beforeRequest: [
options => {
console.log(options.url.toString());
// => https://example.com?foo=bar+baz
}
]
}
});the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sindresorhus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can get the rendered URL in a few ways:
after the request completes:
before the request is sent (to debug encoding):
the
beforeRequesthook is the best way to see exactly whats being sent, including how searchParams are encoded.