0

On the client-side, I am redirecting using the syntax as window.location.href=url and reaching server-side(express) after performing few actions, from there again redirecting with a URL (res.redirect(url)).

Here, both the URLs are the same but along with the URL sent from the server-side am passing few parameters. So, how to fetch those parameters on the client-side (javascript).

swedha b
  • 135
  • 1
  • 2
  • 17
  • You mean query string? like "example.com/path?foo=bar&baz=qux" – barbarbar338 Mar 10 '21 at 07:18
  • Just to be sure that I understood the question; query string can be used to write data on the url. Using that you can read the URL and do whatever you want with the data. https://en.wikipedia.org/wiki/Query_string – Can Oezlemis Mar 10 '21 at 07:19
  • I think he means https://stackoverflow.com/a/26565508/1235106 – Kevin Mar 10 '21 at 07:19
  • (Just FYI, with different query strings, these URLs are _not_ the same.) – CBroe Mar 10 '21 at 07:22
  • @kevin, I tried to fetch it using window.location.search but it didn't work. Initially as I redirected from the client, I don't know how to get the response – swedha b Mar 10 '21 at 07:27
  • For eg: If we send using window.location.href= "aurl.com/link=anotherurl.com" from client-side (passing the link parameter to server so that later point I need to append that link ) and perform few action in server-side and from there redirecting using res.redirect("anotherurl.com&params="+parameters). Now how to access the parameters in "anotherurl.com" in client-side javascript – swedha b Mar 10 '21 at 07:41
  • @barbarbar338, query string only but how to get it for the redirected response – swedha b Mar 10 '21 at 08:01
  • i guess you are looking for this one https://stackoverflow.com/a/901144/10124281 – barbarbar338 Mar 10 '21 at 12:20

0 Answers0