https api request is not working with https.get(url)

I need to pull the weather API data from

It gives a response when pasted in the web browser as well as in postman. But, once incorporated in javascript https.get it fails by continuously loading the browsers and hanging the terminal with unwanted informations.

app.js :

//jshint esversion:6

const express = require("express");
const https = require("https");

const app = express();

app.get("/",function(req, res){

  const url = "";


      const weatherData = JSON.parse(data);
      const temp = weatherData.current.temp_c;
      const weatherDescription = weatherData.current.condition.text;

  res.send("Server is up and running");


app.listen(3000, function(){
  console.log("Started on port 3000");

43 thoughts on “https api request is not working with https.get(url)”

Leave a Comment