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

Get with header isn't working #24

Open
RichardJECooke opened this issue Jul 8, 2016 · 3 comments
Open

Get with header isn't working #24

RichardJECooke opened this issue Jul 8, 2016 · 3 comments

Comments

@RichardJECooke
Copy link

RichardJECooke commented Jul 8, 2016

Please put a line in the documentation explaining how to set headers in a get. It works in superagent but I can't figure out how to do it in superagent-promise. These both fail:

const result = await superagent('GET', url).set('token', testData.token).end();

const result = await superagent.get(url).set('token', testData.token).end();

@clayreimann
Copy link
Collaborator

@RichardJECooke I can't speak to using the new await syntax, but superagent.set does work. Have you looked at what the compiled code looks like for these snippets?

@RichardJECooke
Copy link
Author

The await part isn't relevant, it just compiles down to yield or something.

But can you please give example code for superagent.get with a header that you use? There's none on the homepage and it's the only thing I can't get to work. POST works fine.

@clayreimann
Copy link
Collaborator

clayreimann commented Jul 11, 2016

I linked to https://github.com/yahoo/elide-js/blob/master/lib/datastores/jsonapidatastore.js#L975-L977 in my comment to a function we are using to set headers on a superagent-promise wrapped instance of superagent for GET, POST, PATCH, and DELETE.

I can't speak to the capacity of this library to function using ES7+ features. We don't use anything beyond ES2015, if it doesn't work and you need it to feel free to submit a PR.

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

2 participants