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

176
Views
External API fetch() failure JavaScript

I am learning how to use the fetch() API in JavaScript. Right now i am trying to convert some code i have that is using curl to request data from an external API (aviationstack.com) in my php, and replace it by AJAX calls. I am using their free plan, which doesn't support https, and hence i am trying to fetch from their API using a http URL :

fetch('http://api.aviationstack.com/v1/flights?access_key=myaccesskey').then(function(response) 
{
    //some stuff here
});

This same url works fine with curl in my php code. Issue is the API seems to receive this call as https, since it returns me this json :

{"error":{"code":"https_access_restricted","message":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."}}

Does anyone know what could cause this ? I'm scratching my head over it, and i can't get it to work. Any help would be greatly appreciated, as i don't fully understand this process and i would be glad to get a better understanding of it.

EDIT : It seems i am truly an idiot. This was a network issue all along... Thanks for the answers, much appreciated

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

0

Tried the same using my API key (on my local machine) :

fetch('http://api.aviationstack.com/v1/flights?access_key=<MY API KEY>').then(function(response) 
{
    console.log(response);
});

The console gives the desired response and I get 200 as status. Maybe you should check the API key.

Can you check/provide the Request URL?

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!