Answer the question
In order to leave comments, you need to log in
How to make an asynchronous request in vue-resource?
Hey! With 2 ajax requests through vue-resource, 401 is returned when the token expires.
let allowRefresh = true
Vue.http.interceptors.push((request, next) => {
next((response) => {
if (allowRefresh && response.status === 401) {
allowRefresh = false
store.commit('SET_AUTH_REFRESHING')
return user.refresh(request).then(result => {
return Vue.http(request).then(data => {
return data
})
}, () => {
user.logout()
})
}
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question