external api results not loading in node.js using https module

Viewed 9

whats wrong with my code? its showing no results....although it kinda works when i use google.com as url but in other cases it shows no results*I haven't shared my api key here(appid=)

const express = require('express');
const app = express();
const http = require('http');


app.get("/", function(req, res) {
     
    const url= 'https://api.openweathermap.org/data/2.5/weather?q=london&appid='
    http.get(url, function(response){
        console.log(response);

        //  response.on("data", function(data){
        //     const weatherData = JSON.parse(data); 
        //     const temp = weatherData.main.temp;
        //      // const weatherDescription = weatherData.weather[0].description;
        //     res.send(temp)
        //  })
        // res.send('server is sending');
    })

})      









app.listen(3000, function(req, res){
    console.log('Server is alive')
})
0 Answers
Related