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

728
Views
My GET request works fine in POSTMAN and Curl, but not in JavaScript code

When I make my get request with POSTMAN or Curl, it works just fine and I get the expected response. I just set type to GET, insert my URL and insert a key named token/email and set it to a token/email I get from another service. But when I try to call the same service in code like this:

   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);
        });
    }

I get 401 error. I also found out that the server is not receiving the token in the request header. Any ideas how I can fix this? Cheers.

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

0

To send your token in header use this: 'Authorization': 'Bearer yourToken'

about 4 years ago · Juan Pablo Isaza Report

0

Try to generate code using Postman, lets see if it helps. See attached.

Try to generate code using Postman, let's see if it helps. See attached.

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!