api-pagination
api-pagination copied to clipboard
Access Link header in fetch response
I'm consuming an API that I paginated with your gem. How would I gain access to the link header in the fetch response? I am using React to consume the endpoint, right now when I try response.headers
it's just an empty json object.
fetch('url')
.then(response => {
return response.json()})
.then(data => {
this.setState({recomms: data})
localStorage.setItem('movies', JSON.stringify(data))
})
response.headers.get('Link')
got me access to it 😃
However, looking at other tutorials, the links
come through in the body, and they're not doing that in my response
@mikeyduece What tutorials are you looking at?
This (response.headers.get('Link')
) will work if response type is basic.
else if response type is cors then server restricts the headers you can view to Cache-Control
, Content-Language
, Content-Type
, Expires
, Last-Modified
, and Pragma
.