Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Link header in fetch response #92

Open
mikeheft opened this issue Jan 24, 2018 · 4 comments
Open

Access Link header in fetch response #92

mikeheft opened this issue Jan 24, 2018 · 4 comments

Comments

@mikeheft
Copy link

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))
       })
@mikeheft
Copy link
Author

mikeheft commented Jan 24, 2018

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

@davidcelis
Copy link
Owner

@mikeyduece What tutorials are you looking at?

@saihgal
Copy link

saihgal commented Apr 15, 2019

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.

@himanshi108
Copy link

I can see link in postman , but when I'm doing response.headers.get('Link'), im getting null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants