ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.59k stars 1.33k forks source link

use return #1544

Closed Erkalos closed 4 years ago

Erkalos commented 4 years ago

Hi, I'm a begginer and I don't know why I don't have the result if I do something like this :

exports.sites = function(url) {
    const res = superagent.get(url).set('accept', 'json').catch(console.error).then(res => {
      return JSON.stringify(res.body);
   });
}

The request is working fine. I have the output if I replace return by console.log. I would like to be able to get a return for another function. How I can do that ?

jackfiallos commented 4 years ago

may try to returning res variable after declaration