Parse JSON In Node.js From External URL

Published on April 23, 2019 43 sec read

In one of my articles, I have described about How To Parse JSON In Node.js. In that article I have told some ways to parse JSON without parsing from external URL. Today I am going to share this method with you. Let’s follow these steps:

Table of Contents

  1. Install Request Package
  2. Create a JS File
  3. Run the Project

Step 1 : Install Request Package

Request package helps us to parse JSON from an external URL. Go to your project directory using CMD. Then type this command to install request package:

nmp install request

Step 2 : Create a JS File

We have downloaded the main necessary library for this project. Now create a file named “server.js” in the root directory of your project. Open the JS file with an editor and paste this code:

var request = require("request")

var url = ""

    url: url,
    json: true
}, function (error, response, body) {

    if (!error && response.statusCode === 200) {
        console.log(body) // Print the json response

Step 3 : Run the Project

Our project is ready to run. Let’s run the project and see the output:

node server

When I run the project, I have seen this output:

We have successfully parsed JSON from the external URL. ๐Ÿ™‚

Monthly Newsletter

One email a month, packed with the latest tutorials, delivered straight to your inbox.
We'll never send any spam or promotional emails.

Hey, I'm Md Obydullah. I build open-source projects and write article on Laravel, Linux server, modern JavaScript and more on web development.


4 Replies to “Parse JSON In Node.js From External URL”

Leave a Reply