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

possible bug in setHeader function #505

Closed
Fox155 opened this issue Jun 1, 2021 · 2 comments
Closed

possible bug in setHeader function #505

Fox155 opened this issue Jun 1, 2021 · 2 comments
Labels

Comments

@Fox155
Copy link
Contributor

Fox155 commented Jun 1, 2021

Good afternoon,
when I want to delete the token in the following way

this.$axios.setToken(false, 'Bearer', [ 'get', 'post', 'delete', 'put', 'patch', ])

I noticed that it was not being completely deleted, and after a little digging I came to the conclusion that the setHeader function is returning before going through all the scope.

setHeader (name, value, scopes = 'common') {
for (const scope of Array.isArray(scopes) ? scopes : [ scopes ]) {
if (!value) {
delete this.defaults.headers[scope][name];
return
}
this.defaults.headers[scope][name] = value
}
},

I propose to change that return for a continue, because otherwise only the first element of the scope is deleted.

Greetings.

@pi0
Copy link
Member

pi0 commented Jun 2, 2021

Thanks for notice @Fox155. PR welcome for fix.

@pi0
Copy link
Member

pi0 commented Jun 2, 2021

@pi0 pi0 closed this as completed Jun 2, 2021
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