title: Download a json file from a link using Node js
body: <p>I need to write an application with Node JS which given a link to a json file e.g <a href="http://data.phishtank.com/data/online-valid.json" rel="nofollow noreferrer">http://data.phishtank.com/data/online-valid.json</a> (The link doesn't open the file it opens a download), the program simply downloads the object and then prints it out. How can this be achieved? This is what I have so far and it doesn't seem to be working:</p>
  
  <pre><code>var checkIfPhishing = function(urlToPrint){
      var http = require('http');
      var fs = require('fs');
  
      var file = fs.createWriteStream("SiteObject.json");
      var request = http.get(urlToPrint, function(response) {
      response.pipe(file);});
  
      var siteObj= fs.readFileSync("SiteObject.json");
  
      console.log(siteObj);
  
  };
  </code></pre>
  
  <p>Thank you!</p>