Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda