Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

356
Views
No se obtiene ningún error de valor de encabezado de autorización,

Los encabezados de autorización (token de portador) no se agregan a las llamadas a la API
El estado es 401 No autorizado y los encabezados no se agregan a la llamada a la API.

 const axios = require('axios') let token = 'eyJ0eXAiOiJOiJIUzI1NiJ9.eyJpc3MiOiJJQ00iLCJhdWQiOiJzZXNzaW9uLW1hbm' export class classname ) async getReports () { let response try { response = await axios.get(`https://urltogo/path`), { headers: { 'Content-Type' : 'application/json', Authorization : `Bearer ${token}` } } const responseObj = { url: `GET ${`https://urltogo/path`}`, status: response.status, data: response.data } if (responseObj.data.meta.count == 1) { return responseObj.data.items[0].id } } catch (error) { const errorObj = { status: error.response?.status, data: error.response?.data } throw new Error(JSON.stringify(errorObj)) } } }

Obtener error

 "status":401,"data":{"message":"Unauthorized, **no authorization header value**"}}

datos: error.respuesta?.datos

 not sure what i am missing here in the code
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Debe poner las opciones como segundo argumento del método get , no después de cerrarlo.

 response = await axios.get(`https://urltogo/path`, { headers: { 'Content-Type' : 'application/json', Authorization : `Bearer ${token}` } });
about 4 years ago · Juan Pablo Isaza Report

0

Actualicé la respuesta de @reyno con negrita

 response = await axios.get**(**`https://urltogo/path`,{ headers: { 'Content-Type' : 'application/json', 'Authorization' : `Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ`} } **)**;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!