Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda