devour-js/devour-client

[Question] set withCredentials = true

luizcastrolfc opened this issue · 2 comments

Is there a way to set withCredentials = true?
axios example:
const api = axios.create({ withCredentials: true, ... })

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.

Just to report feedback.
jsonApiInstance.axios.defaults.withCredentials = true
works perfectly.