1

How to fetch params from

props.location.search

where i tried

const { propKey, propEid } =  new URLSearchParams(props.location.search);

but propKey and propEid shows unidentified in console.log

my url is like so:

{{baseurl}}/verify-email?key=a6d16a22a82f16c96ee7d2f95c45c9bc&eid=c2Frc2hpMTFAZ21haWwuY29t

5
  • sample of props.location.search & why are u destructuring URLSearchParams ? Commented Jul 28, 2020 at 14:20
  • 2
    You have to use .get to get values from URLSearchParams. Commented Jul 28, 2020 at 14:31
  • @aXuser264 coz my url has two params in query, updated above Commented Jul 28, 2020 at 15:39
  • @Agney according to my problem above, can you please explain how to get the values of params? something like this? URLSearchParams.get(name) Commented Jul 28, 2020 at 15:41
  • 1
    @Sakshi doesn't matter, URLSearchParams can handle that (as Agney pointed out) checkout developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/… Commented Jul 29, 2020 at 1:15

1 Answer 1

1
const params = new URLSearchParams(props.location.search);
const key = params.get('key'); // a6d16a22a82f16c96ee7d2f95c45c9bc&eid=c2Frc2hpMTFAZ21haWwuY29t
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.