0

How would I go about extracting a "parameter" or "argument" from a hash in a url?
https://example.com/blahblahblah#key=value&scope
An API is giving me a weird token that is in a long URL and I need to get it from the hash, but it is in this weird format
React Native does not support the URLsearchparams functions in JavaScript

I get key=value&scope but I need value

Nash Anderson
  • 70
  • 1
  • 8
  • 2
    `new URLSearchParams(new URL(url).hash.replace(/^#/, '')).get('key')` – CherryDT Dec 13 '21 at 00:45
  • Just a note on the duplicate... yes the linked post is about actual query string but since OP's hash is in the same format (`application/x-www-form-urlencoded`), the same answers apply – Phil Dec 13 '21 at 00:51
  • Probably should have mentioned this is react native, URLSearchParams doesn't work – Nash Anderson Dec 13 '21 at 01:16

0 Answers0