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

182
Visualizações
Why Is My API Response Not Automatically Being Logged To My Terminal Console?

I'm just starting to delve into Api's via a course and essentially I am trying to pull in data from the open weather api for London. It's working IF i manually request it to console log the response via terminal (I'm on MAC) but not doing so automatically, even though it's referenced in the code. I'll paste my code below but remove my api key for obvious reasons.

Any help would be appreciated, thanks in advance for your time.

const express = require('express');
const https = require('https');
const app = express();
const port = 3000;
const url = 'https://api.openweathermap.org/data/2.5/weather?q=London&appid=12345mykeyexample'; 

//set route as index.html
app.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html');
  
  //get api url and console log response
  https.get(url, function(response){
    console.log(response);
  });
  res.send('server is up and running bro');
});


// listen on port 3000
app.listen(port, () => {
  console.log(`Server started bro http://localhost:${port}`);
}); 
about 4 years ago · Juan Pablo Isaza
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