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

288
Vistas
SyntaxError: Unexpected end of JSON input. at JSON.parse (<anonymous>)

I'm a new developer learning how to work with API's and I've run into this error a few times now that keeps crashing Node:

SyntaxError: Unexpected end of JSON input at JSON.parse () at IncomingMessage. (/Users/dharmendrasingh/Desktop/WeatherProject/app.js:13:28)

I'm not really sure how to resolve it or what the problem is exactly... my JS code looks like this:

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

const app = express();

app.get("/", function(req, res){
  const url = "https://postman-echo.com/get?q=London&appid=639179c2c6d4f4db9c4657a69ac05438&units=matric";

  https.get(url, function(response){
    console.log(response.statusCode);

    response.on("data", function(data){
      const weather = JSON.parse(data);
      console.log(weather);

    });

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


app.listen(3000, function(req, res){
  console.log("Server is running at port: 3000.");
});
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