Saturday 8 April 2017

how to send a response from a superagent promise

very new to Node.js/express/JS :)

trying to send a response from superagent callback function, but definitely doing something wrong;

var request = require('superagent');

exports.list = function(req, res, next){

  request
  .get('http://blah-blah')
  .then(function onResult(res) {
      //res.send(res.body)
      //res.status(200).json({status:"ok"})
  }, function onError(err) {
    console.log('err');
  });

Thanks in advance!



via tania

No comments:

Post a Comment