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

270
Vistas
Node : Put request is not updating the request data on the browser but updates on Command Line, Weather API

I'm a beginner in Node, as I try to update the API request(Weather API) in the browser it never changes but if I try to run on command line it forecast the live weather.

const express = require("express");
const { all } = require("express/lib/application");
// HTTPS library requrired`
const https = require("https");
const app = express();
const port = 3000;
app.get("/", function(req, res){

    // Getting data from external server
    const url = "https://api.openweathermap.org/data/2.5/weather?q=Mumbai&appid=---------------------------------&units=metric";

    // Adding functions to our own server
    https.get(url, function(respone){
        console.log(respone.statusCode);

        // Getting data and putting on our server
        respone.on("data", function(data){

            // Parsing the data to an actuall javascript object
            var allData = JSON.parse(data)
            const temp = allData.main.temp;
            const description = allData.weather[0].description;
            const icon = allData.weather[0].icon;
            const imageUrl = "http://openweathermap.org/img/wn/"+ icon +"@2x.png"
            res.write("<p>The weather type here is: "+description+"</p>")
            res.write("<h1>The temperature here is: "+temp+"</h1>")
            res.write("<img src = "+imageUrl+"></img>");
            res.send();
            console.log(allData)
        })
    })
})

app.listen(port, function(){
    console.log("Server is running on port 3000");
})

Command Line image Browser Image

about 4 years ago · Juan Pablo Isaza
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