title: Node.js - Why does my HTTP GET Request return a 404 when I know the data is there @ the URL I am using
body: <p>I'm still new enough with Node that HTTP requests trip me up. I have checked all the answers to similar questions but none seem to address my issue.</p>
  
  <p>I have been dealt a hand in the Wild of having to go after JSON files in an API. I then parse those JSON files to separate them out into rows that populate a SQL database. The API has one JSON file with an ID of 'keys.json' that looks like this:</p>
  
  <pre><code>{
  "keys":["5sM5YLnnNMN_1540338527220.json","5sM5YLnnNMN_1540389571029.json","6tN6ZMooONO_1540389269289.json"]
  }
  </code></pre>
  
  <p>Each array element in the keys property holds the value of one of the JSON data files in the API.</p>
  
  <p>I am having problems getting either type of file returned to me, but I figure if I can learn what is wrong with the way I am trying to get 'keys.json', I can leverage that knowledge to get the individual JSON data files represented in the keys array.</p>
  
  <p>I am using the npm modules 'request' and 'request-promise-native' as follows:</p>
  
  <pre><code>const request   = require('request');
  const rp        = require('request-promise-native');
  </code></pre>
  
  <p>My URL is constructed with the following elements, as follows (I have used the ... to keep my client anonymous, but other than that it is a direct copy:</p>
  
  <pre><code>let baseURL = 'http://localhost:3000/Users/doug5solas/sandbox/.../server/.quizzes/'; //  this is the development value only
  let keysID = 'keys.json';
  </code></pre>
  
  <p>Clearly the localhost aspect will have to go away when we deploy but I am just testing now.</p>
  
  <p>Here is my HTTP call:</p>
  
  <pre><code>let options = {
      method: 'GET',
      uri: baseURL + keysID,
      headers: {
          'User-Agent': 'Request-Promise'
      },
      json: true // Automatically parses the JSON string in the response
  };
  rp(options)
      .then(function (res) {
          jsonKeysList = res.keys;
          console.log('Fetched', jsonKeysList);
      })
      .catch(function (err) {
          // API call failed
          let errMessage = err.options.uri + ' ' + err.statusCode + ' Not Found';
          console.log(errMessage);
          return errMessage;
      });
  </code></pre>
  
  <p>Here is my console output:</p>
  
  <pre><code>http://localhost:3000/Users/doug5solas/sandbox/.../server/.quizzes/keys.json 404 Not Found
  </code></pre>
  
  <p>It is clear to me that the .catch() clause is being taken and not the .then() clause. But I do not know why that is because the data is there at that spot. I know it is because I placed it there manually.</p>