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
  • Please share your code Commented May 26, 2020 at 8:21

1 Answer 1

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');
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.