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

730
Views
Mi solicitud GET funciona bien en POSTMAN y Curl, pero no en código JavaScript

Cuando hago mi solicitud de obtención con POSTMAN o Curl, funciona bien y obtengo la respuesta esperada. Simplemente configuro el tipo en GET, inserto mi URL e inserto una clave llamada token/email y lo configuro en un token/email que recibo de otro servicio. Pero cuando trato de llamar al mismo servicio en un código como este:

 function getAll() { const myHeaders = new Headers({ 'Accept': 'application/json', 'token': 'MY TOKEN', 'email': 'MY EMAIL' }); return fetch('https://apitul', { headers: myHeaders, method: 'GET' }) .then(response => { if (response.status === 200) { return response.json(); } else { throw new Error('Something went wrong on api server!'); } }) .then(response => { console.debug(response); }).catch(error => { console.error(error); }); }

Me sale el error 401. También descubrí que el servidor no recibe el token en el encabezado de la solicitud. ¿Alguna idea de cómo puedo arreglar esto? Salud.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Para enviar su token en el encabezado, use esto: 'Autorización': 'Bearer yourToken'

about 4 years ago · Juan Pablo Isaza Report

0

Intenta generar código usando Postman, veamos si ayuda. Ver adjunto.

Intenta generar código usando Postman, veamos si ayuda. Ver adjunto.

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!