0

I'm trying to fetch URL query params with react-router by access to props.location.query, but the query is undefined. how can fetch them?

URL example - http://localhost:3000/home?param1=tomato&param2=potato

1 Answers1

0
//Try this way without any lib.
const query = new URLSearchParams(this.props.location.search); 
const param1 = query.get('param1');
const param2 = query.get('param2');
Nainish Modi
  • 405
  • 2
  • 10