Axios instance interceptors not working
-
i have the following code
import Vue from 'vue' import axios from 'axios' import {Notify} from 'quasar' const instance=axios.create({ baseURL:"http://newsapi.org/v2", params:{ apiKey:"//someKey" } }); instance.interceptors.response.use((config)=>config,error=>{ if(error.response.status==400) Notify.create({ type:"negative", message:"Hello there!" }); }); Vue.prototype.$axios = instance;
I dont know why but the interceptor is not even triggered on any response i checked this by logging text to console in first as well as in second parameter’s body.
-
@Abdullah-Sohail working fine on mine, maybe return the
Promise.reject(error)
like in axios interceptor signature at ghreturn Promise.reject(error)
. -
@metalsadman after too much trouble i was finally able make it work BUT for only response error like 429 which was specific to a third party news api on the other hand i am using firebase auth (REST) to authenticate user if a user puts a invalid password then an error response is sent back by firebase and i am trying to catch that here in the interceptor ( error like 420 ) but its still not getting caught by the interceptor is this problem specific to firebase or what?
-
@Abdullah-Sohail i don’t know, you should check in your network tab, see what error code they(firebase) returned.