The Old County
The Old County

Reputation: 89

reactjs -- how to put object data cleanly into a url - but also how to access those parameters?

I am working on a react js application - and I need to create a redirect - that will go to a url - with a bunch of params -- an id, then multiple terms - key/value pair type approach

data

id = 23 terms = {"budget": "how does it look now", "gender": "male", "age": 32}

so the url will look something like this partnerspage?id=23&terms[budget]=how does it look now&terms[gender]=male&terms[age]=32

-- and then on this partners page in the component did mount

I want to gain access to this data -- so - I'm using routing and on some pages I have the routing using forward slash activate/{token} --

would the listener for these params be something like

console.log("params", this.props.location.search)? -- how would I get the data from the url?

Upvotes: 0

Views: 47

Answers (1)

Anuja
Anuja

Reputation: 1038

Added a sandbox for the solution i mentioned in the comment, check it out, lmk if there is an issue.

https://codesandbox.io/s/nameless-framework-w0grj?file=/src/Main.js

Upvotes: 1

Related Questions