Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!