Open bagaskarala opened 3 years ago
@bagaskarala You may update it like below,
$axios.onRequest((config) => {
// #1 api
if (config.url.startsWith('/first-api')) {
const imersToken = Vue.$cookies.get($config.firstToken)
config.headers.Authorization = `Bearer ${imersToken}`
}
// #2 api
if (config.url.startsWith('/second-api')) {
const evmToken = Vue.$cookies.get($config.secondToken)
config.headers.Authorization = `Bearer ${evmToken}`
}
})
i setup interceptor like this, there is two apis with two different token, so i handle using url.
but when i call first-api and second-api at the same time, some of them doesn't populate with the token so it result in Error 401. it will fine if i hit same api at the same time. is this bug or it is my worst practice?