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

170
Views
Can't make a get request with header to an api

I'm trying to make a get request to an api,but there is en error: Failed to fetch, what might be wrong here?

const getData = () => {
  fetch("https://test-docs.stores.kg/api/categories", {
    method: "GET",
    headers: {
      secretKey: "test_key",
      accept: "application/json "
    }
  })
    .then((res) => res.json())
    .then((res) => console.log(res));
};

getData();

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

0

Seems like the API you're querying is not setting a CORS header (check for reference https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). Therefore your request is being blocked. cors_issue

If you are in control of this API adjust the webserver settings to set the appropriate header: e.g.

  • "Access-Control-Allow-Origin: https://YOUR_WEB_FRONTEND_DOMAIN.TLD"
  • (or if you just want to get it to work in a development setup) "Access-Control-Allow-Origin: *"

You can also test the API in this Tool here https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=%20https%3A%2F%2Ftest-docs.stores.kg%2Fapi%2Fcategories&server_enable=true&server_status=200&server_credentials=false&server_tabs=remote

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!