Closed Azurox closed 4 years ago
Hi @Azurox,
Is there a way to delete the Auth header without recreating the entire wrecht object ?
I think that the following code should do the trick:
function removeAuth(w) {
const headers = { ...w._options.headers }
delete headers['Authorization']
return w.options({ headers }, false)
}
const base = wretch('/').auth('token')
/* With Authorization header */
base.get().text(console.log)
/* Without Authorization header */
// The imperative way:
removeAuth(base).get().text(console.log)
// The declarative way:
base.defer(removeAuth).get().text(console.log)
@Azurox closing the issue, feel free to reopen if you have other related questions
@elbywan it would be nice if there was a way to completely strip a certain header from a wretch instance
delete w.defaults.header.Authentication
when a user logs out the Authentication
header should no longer exist on the instance.
@elbywan If you want I can try to submit a PR to add/fix this.
Hey @a-eid,
it would be nice if there was a way to completely strip a certain header from a wretch instance
Unless I'm mistaken, I think that the code snippet above does exactly that?
Hi, Is there a way to delete the Auth header without recreating the entire wrecht object ? I tried :
api = api.auth(null);
api = api.auth(undefined);
api = api.auth();
And the authorization is still present in every request with either
null
orundefined
as valueThank you 😄