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

198
Vistas
JwtIntercepter set header in typescript

Im try to do Ionic&Vue JWT(JSON Web Token) Authentication using Vuex. While implementing JwtInterceptor in ts file In this line config.headers.common["Authorization"] = bearer ${authData.token} i am getting error .

In the Authorization, I am getting errors like "Element implicitly has an 'any' type because index expression is not of type 'number'"

In the config. headers I am getting errors like "Object is possibly 'undefined'."

authorization error config error

Here is the code in jwtinterceptor.ts file

import axios from "axios";
import store from '../store/index';

const jwtInterceptor = axios.create({});

jwtInterceptor.interceptors.request.use((config) => {
    const authData=store.getters["auth/getAuthData"];
    console.log("auth data in jwtInterceptor",authData);
    config.headers.common["Authorization"] = `bearer ${authData.token}`;
    return config;
});

export default jwtInterceptor;

In the Js file all is fine. not in .ts file, any help will be appreciated.

about 4 years ago · Juan Pablo Isaza
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