title: Read a file using HTTP in Node.JS
body: <p>In my dev-environment I prefer to read data from a file instead from the actual API because of performance reason.</p>
  
  <p>I tried to do this like this:</p>
  
  <pre><code>var path = process.env.NODE_ENV === 'production' ? '/pathToExternalApi...' : process.env.pwd + '/assets/mockdata.json';
  
  http.get(path, function (resFromApi, err) {
  
    var body = '';
  
    resFromApi.on('data', function (chunk) {
      //console.log(chunk);
      body += chunk;
    });
  
    resFromApi.on('end', function () {
      //console.log(resFromApi.statusCode + ' path:' + path);
      if (resFromApi.statusCode === 200) {
        cb(JSON.parse(body));
      } else {
        cb(null, 'Statuscode: ' + resFromApi.statusCode);
      }
    });
  })
  </code></pre>
  
  <p>I get 404 when I try to run against file. I've checked that the path is correct. </p>
  
  <p>Cant I use <code>http.get()</code> when to fetch data from file? How do I do this instead?</p>