A
A
Alexey Malyshev2018-10-09 11:24:44
React
Alexey Malyshev, 2018-10-09 11:24:44

How to navigate to an element's page when used on a HAL backend?

Links are returned from the server.
We display a general list of elements on the page by a general request, but how to make a button to view one element? If HAL were not used, then I would do the transition by id, but what if with HAL?
JSON example from server

"_links" : {
    "self" : {
      "href" : "http://localhost:8080/books/book/1"
    },
  },

Here is a link to get the data of a specific book. As I understand it, we pass it to the next page in order to make a request and get all the data, but how to make the address of the desired page so that when the page is updated, just such a request remains. I thought that the page address would be the same as _links, but we need a relative path. Of course, you can chop off href to the third slash, but I think this is wrong

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2018-10-09
@inoise

You can use templated. Dynamic links based on parameters. And then rely on attributes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question