2017 answer: you can now do exactly what you want in every current browser and Node.js
This is quite simple:
- Return a Promise
- Use the 'await', which will tell JavaScript to await the promise to be resolved into a value (like the HTTP response)
- Add the 'async' keyword to the parent function
Here's a working version of your code:
(async function(){ var response = await superagent.get('...') console.log(response)})()