axios global request interceptor needs to request a method to get the return value in return config
because the method is requested asynchronously, so use Promise
axios.interceptors.request.use(config => {
return new Promise(resolve => {
window.__nativeFn("js_getAllDeviceInfo", {
// ios
response: r => {
config.data = Object.assign(config.data, r.data)
// window.vue.$Tips.info(r.data, 2000)
resolve(config)
}
})
})
}, error => {
return Promise.reject(error)
});
when a page has only one request, this is ok. When a page has more than one request, the config of the last request will overwrite the config of all previous requests and only send one request. I don"t know why. What should we do if we solve the problem? Or in what way I can achieve the desired results and wait for the ios response in return config