Skip to content

possible bug in setHeader function #505

@Fox155

Description

@Fox155

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions