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

When headers is null, auth header is removed #52

Closed
PierBover opened this issue Jul 11, 2019 · 2 comments
Closed

When headers is null, auth header is removed #52

PierBover opened this issue Jul 11, 2019 · 2 comments
Labels

Comments

@PierBover
Copy link

PierBover commented Jul 11, 2019

I set the auth header like this which works fine:

api.auth(`Bearer ${ token }`);

On some requests I need to pass headers, but not others. I have a generic method for doing POST requests so sometimes headers is undefined and it seems the Authorization header is removed:

api.headers(headers)

I've resorted to doing this:

api.headers(headers || {})

It works, but it doesn't seem like .headers() should be messing with the auth header set with .auth(), no?

@elbywan elbywan added the bug label Jul 11, 2019
@elbywan
Copy link
Owner

elbywan commented Jul 11, 2019

Hi @PierBover,

It works, but it doesn't seem like .headers() should be messing with the auth header set with .auth(), no?

Indeed this is an issue, thanks for the report! Passing null or undefined as an argument to .headers() should not mess with the headers that were previously set.

I just released the 1.5.3 which contains the fix 👍.

@PierBover
Copy link
Author

Awesome! Thanks for the quick fix!

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

No branches or pull requests

2 participants