edit2: https://stackoverflow.com/a/4168328/216832 assumes that I do not need to worry, because this does not happen when on a real device.
I use Axios in a VueJS hybrid application (Cordova) and call the API.
Axios (correctly) makes a "preflight" request OPTIONSbefore my GET/ requests POST, but if the API returns 503at that moment, my error handling code is not called.
OPTIONS
GET
POST
503
HTTP.post(url, data, {headers: {Authorization: 'Bearer ' + token.getAccessToken()}}) .then(response => response) .catch(error => { // Not reached });
How can I catch this error status?
edit : screenshot from Chrome Dev Tools:
,
axios.interceptors.response.use(null, (error) => { return Promise.reject(error); });
Network Error . , - , , , , :
Network Error
instance.interceptors.response.use(null, error => { if (error && error.message === 'Network Error') { throw new Error('Potential network CORS preflight error at ${error.config.url}'); } throw error; });