Closed stefanullinger closed 1 year ago
Hey!
You can take the query part out of the link and pass it as queryParams
.
I imagine it as something like that:
const next = 'https://my.api/books?page=1&size=10&sort=desc'
const queryParams = next.split("?")[1]; // No worries, HF will automatically add question mark in the final query
const getBooks = client.createRequest()({ endpoint: '/books' })
getBooks.setQueryParams(queryParams); // Use prepared query params, everything will get cached and handled by HF
However, there is no direct method to take `_links.next.href` and put it directly into request, HF requires declarations first.
I hope this help! 👍🏻
Hey @prc5, thanks a lot - did not see this option, although it is so obvious!
Hi, in my current project, I am asked to use HAL resource links to load more items for a resource.
These resource links contain a full URL. The problem is, that the Hyper Fetch client already contains a baseURL for all request, which then ends up being prepended to the full URL of the resource links.
I would like to know, if there already is a way to request these resource URLs using the same client and without modifying the URL before the request is made by the HyperFetch client.
For example, imagine there is a books resource and I would like to show a paginated list of books. Requesting the books resource, the API would response with something like this:
After getting the response, I would like to grab the URL of
_links.next.href
and request the next books from the API.Is there any way to do this with HyperFetch without replacing the base URL of this URL string?