2

My question is pretty simple. I try to use the URLSearchParams API. In my Google chrome browser console I got an empty object returned.

I simply applied the example given here google example

// Can also constructor from another URLSearchParams
const params = new URLSearchParams('q=search+string&version=1&person=Eric');

console.log(params.get('q') === "search string");
console.log(params.get('version') === "1");
console.log(Array.from(params).length === 3);

But I always got an empty object

console output

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
jossefaz
  • 3,312
  • 4
  • 17
  • 40
  • 1
    Not sure what the issue is, but I got completely different responses in the console using the inputs you provided. `Object.fromEntries(params)` worked fine as well – Rod911 Mar 08 '21 at 11:09
  • 2
    I converted you code into a live demo and can't reproduce the problem – Quentin Mar 08 '21 at 11:12
  • 1
    im getting `true` `true` `true`.. did you modify your browser in some strange way? – The Bomb Squad Mar 08 '21 at 11:13
  • ...e.g. like prototype modifications? – FZs Mar 08 '21 at 11:14
  • No. I did not modified anything in my browser....a plain Google Chrome browser – jossefaz Mar 08 '21 at 11:14
  • 1
    so we can agree the problem is something more than `URLSearchParams`? – The Bomb Squad Mar 08 '21 at 11:18
  • If you run the snippet in this post, what do you get? – FZs Mar 08 '21 at 11:34
  • weird....I tried to reinstall chrome but it still does not work. Anyone has an idea from where I could start searching what could be the problem ? – jossefaz Mar 08 '21 at 13:36
  • @FZs : I ran this snippet in chromium and it worked perfectly....but in plain chrome brwoser it does not work ...seems to be a really weird issue with chrome. I do not know how to prevent it from other browser to occured... I'll try to search for an alternative – jossefaz Mar 08 '21 at 15:03
  • @jossefaz This seems to have nothing to do with the browser. Chrome uses Chromium, so they should be the same. What site were you on when testing for the first time? That site could've modified it. – FZs Mar 08 '21 at 15:43
  • @FZs I tested all this on different website...but mainly on my localhost (React 17+ Dev) – jossefaz Mar 08 '21 at 15:45
  • @jossefaz Were you able to repro this on any site other than your own? – FZs Mar 08 '21 at 15:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/229657/discussion-between-jossefaz-and-fzs). – jossefaz Mar 08 '21 at 15:59

0 Answers0