You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everybody, I have a problem about the Interceptors. sometime when I'm fetching api, it will timeout, because I set axios.defaults.timeout = 6000. The problem is I want to fetch again and bring something I have already coded. just take a look at these code below:
this action sometime would timeout.
this.$axios.get('http://www.google.com/this-page-doesnt-exist.html').then(function (response) {
console.log('Yes, I have a iphone X.');
//....or a lot of code....
})
so I use interceptors to fetch again, but I have a hook above console.log('Yes, I have a iphone X.'), How can I make interceptors inherit the hook?
axios.interceptors.response.use(function(response){
return response;
}, function(error){
if(error.code == 'ECONNABORTED' && error.message.indexOf('timeout')!=-1){
axios({
url:error.config.url,
method:error.config.method,
params:error.config.params,
data:error.config.data || ''
}).then(function (response) {
console.log('Do you have an iPhone?')
//it should print Yes, I have a iphone X.
});
}
return Promise.reject(error);
})
The text was updated successfully, but these errors were encountered:
ssttm169
changed the title
Interceptors? How can I fetch again and bring something I have already done?
Interceptors? How can I make the interceptors inherit the hook?
Oct 13, 2017
Hi everybody, I have a problem about the Interceptors. sometime when I'm fetching api, it will timeout, because I set
axios.defaults.timeout = 6000.
The problem is I want to fetch again and bring something I have already coded. just take a look at these code below:this action sometime would timeout.
so I use interceptors to fetch again, but I have a hook above
console.log('Yes, I have a iphone X.')
, How can I make interceptors inherit the hook?The text was updated successfully, but these errors were encountered: