Search code examples
yieldsuperagent

Using yield with superagent returns request object instead of response


According to SuperAgent docs: SuperAgent docs

var res = yield request
  .get('http://local')
  .auth('tobi', 'learnboost')

However, I'm finding that the var res isn't res, its req. Meaning I have only access to the request object, not the response object with the fetched data that is usually passed to the end() chainable, which is obviously what I need.

Anyone experience with this? Am I missing something?


Solution

  • Although your question was answered on GH, figured I'd paste it here as well for others. The following worked great for me!

    var res = yield Promise.resolve(request
    .get('http://local')
    .auth('tobi', 'learnboost'))