No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Axios instance interceptors not working

    Help
    2
    4
    613
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Abdullah Sohail last edited by

      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.

      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @Abdullah Sohail last edited by

        @Abdullah-Sohail working fine on mine, maybe return the Promise.reject(error) like in axios interceptor signature at gh return Promise.reject(error).

        1 Reply Last reply Reply Quote 0
        • A
          Abdullah Sohail last edited by

          @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?

          metalsadman 1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman @Abdullah Sohail last edited by metalsadman

            @Abdullah-Sohail i don’t know, you should check in your network tab, see what error code they(firebase) returned.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post