If I do the following http call to my api on resource /people and return
{
"_embedded": {
"people": [
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"_links": {
"self": {
"href": "http://localhost:8080/person/1"
},
"person": {
"href": "http://localhost:8080/person/1"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:8080/person"
}
}
}
The data is being rendered on screen in a table and currently I expose my id's from my backend and use the following link for my react-router
to handle
<Link to={`person/${this.props.person.id}`}>Detail</Link>
Here I can't pass the link in the rendered link and have to pass the id to do the detail call in my backend. But instead of constructing the href
manually I want to use the url at _links.self.href
in my next component.
How can I achieve this without exposing id's in my React application?