Using yield with superagent returns request object instead of response

妖精的绣舞 提交于 2019-12-25 03:45:11

问题


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?


回答1:


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'))


来源:https://stackoverflow.com/questions/35921605/using-yield-with-superagent-returns-request-object-instead-of-response

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!