Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda