I am trying to make a call to an API to grab some data. When the call returns valid data, it works! However, when it hits a API error, or an error I want to create based off the data response, I get this error:
Unhandled rejection Error: Data not found!
at Request.request.post [as _callback]
.
.
These are the files I am using:
let grabSomeData = new BluebirdPromise((resolve, reject) => {
  pullers.grabData(dataID, (err, res) => {
    if (err) {
      return reject(err);
    }
    return resolve(res);
  });
});
grabSomeData.then((fulfilled, rejected) => {
  console.log('res: ' + fulfilled);
  console.log('rej: ' + rejected);
});
In my other file making the http request,
grabData(dataID, grabDataCallback)  {
  let bodyObj = {
    query: dataByIDQuery,
    variables: {
      id: dataID
    }
  };
  // grab the data
  request.post(
    {
      url: dataURL,
      body: JSON.stringify(bodyObj)
    }, (err, httpResponse, body) => {
        if (err) {
          return grabDataCallback(err);
        }
        let res = JSON.parse(body);
        if (res.data.dataByID !== null) {
          return grabDataCallback(null, res.data.dataByID);
        }
        return grabDataCallback(Boom.notFound('Data not found!'));
      }
  );
}
 
     
     
    