title: Return an API response from a Promise.then()
body: <p>Im writing an API call that uses async Promise with express and bluebird.
  I have the following code:</p>
  
  <pre><code>router.get('/', (req, res) =&gt; {
    log.debug('api - v2 - Koko Version api call');
    if (req.query.prop) {
      serverStatus.transform(req).then((data) =&gt; {
        switch (req.query.prop) {
          case 'KokoVersion': {
            return res.status(200).json({KokoVersion: data.version});
          }
          case 'KokoType': {
            return res.status(200).json({KokoType: data.deviceType});
          }
          case 'LastChangeTime': {
            return res.status(200).json({LastChangeTime: data.lastApply});
          }
        }
      }).catch((error) =&gt; {
        log.debug('Failed returning from Promise.resolve - v2 properties API');
      });
    }
    return res.status(500).json({status: 'ERROR', message: 'Internal Server error'});
  });
  </code></pre>
  
  <p>the transform methoid returns a new Promise() which generates the data used in the then() call seen above(in the 4th line) however I cant seem to return a response with the fields created from the data above. So my question is - How do I respond to an API call when the evaluation of that call needs to go through a flow of Promise --> resolve --> then? </p>