Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
VueJS - Axios Interceptors not recieving 401 response

I am trying to have a request and response interceptor setup for Axios when I make Post requests, however I can only get the request interceptor to respond, and nothing else, I've included an example of it not running:

Here is the axios setup:

import axios from "axios";

axios.defaults.baseURL = "https://btk7dl15c9.api.quickmocker.com";

axios.interceptors.request.use(
  async (config) => {
    console.log("request ok");
    return config;
  },
  (error) => {
    console.log("request error");
    return Promise.reject(error);
  }
);
axios.interceptors.response.use(
  (response) => {
    console.log("response ok");
    return response;
  },
  (error) => {
    console.log("response error");
    return Promise.reject(error);
  }
);

export default {
  methods: {
    axiosPost(url, data) {
      return axios.post(url, data);
    }
  }
};

https://codesandbox.io/s/keen-shockley-xccsx

I need to be able to intercept 401 to be able to make a token refresh call (not included with the example)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You used "axios": "0.21.2" which it seems to have a bug in the interceptor that they fixed in v0.21.3

if you up to 0.21.3 or down to 0.21.1 this should fix your issue.

checkout the release log : https://github.com/axios/axios/releases/tag/0.21.3

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda