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

288
Visualizações
vue 3 and axios returns error with overload

Currently using vue 3/ vite/ axios / typescript. My function works in dev. In my IDE it returns an error in the ide and during build though.

get count() {
      axios({
        method: "get",
        url: "/info/count",
        headers: authHeader(),
      })
        .then((response) => {
        this.count = response.data.status;
      });
    },

Error in IDE Pycharm

TS2769: No overload matches this call.   Overload 1 of 2, '(config: AxiosRequestConfig<any>): AxiosPromise<any>', gave the following error.     Argument of type '{ method: "get"; url: string; headers: { Authorization: string; } | { Authorization?: undefined; }; }' is not assignable to parameter of type 'AxiosRequestConfig<any>'.       Object literal may only specify known properties, and 'headers' does not exist in type 'AxiosRequestConfig<any>'.   Overload 2 of 2, '(url: string, config?: AxiosRequestConfig<any>): AxiosPromise<any>', gave the following error.     Argument of type '{ method: string; url: string; headers: { Authorization: string; } | { Authorization?: undefined; }; }' is not assignable to parameter of type 'string

Values in AuthHeader()

export default function authHeader () {
   
        let user_token = localStorage.getItem('auth_user')
        let auth_token = localStorage.getItem('auth_token')

        if (user_token && auth_token) {
            return { 'Authorization': 'bearer ' + auth_token };
        } else {
            return {};
        }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try the headers in curly braces {}, as in:

axios({
        method: "get",
        url: "/info/count",
        {headers: authHeader()},
      })
        .then((response) => {
        this.count = response.data.status;
      });
about 4 years ago · Juan Pablo Isaza Relatório
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