[Question] set withCredentials = true
luizcastrolfc opened this issue · 2 comments
luizcastrolfc commented
Is there a way to set withCredentials = true
?
axios example:
const api = axios.create({ withCredentials: true, ... })
tomers commented
I think a middleware could do the trick:
let requestWithCredentialsMiddleware = {
name: 'with-credentials',
req: (payload) => {
payload.withCredentials = true
return payload
}
}
And use it here:
jsonApiInstance.insertMiddlewareBefore('axios-request', requestWithCredentialsMiddleware)
Or maybe setting defaults would be a simpler solution:
jsonApiInstance.axios.defaults.withCredentials = true
I haven't tried either of these. Please report your findings.
sk-pub commented
Just to report feedback.
jsonApiInstance.axios.defaults.withCredentials = true
works perfectly.