本文介绍了将yield与superagent一起使用将返回请求对象而不是响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据SuperAgent文档: SuperAgent文档
According to SuperAgent docs: SuperAgent docs
var res = yield request
.get('http://local')
.auth('tobi', 'learnboost')
但是,我发现var res不是res,它是req.这意味着我只能访问请求对象,而不能访问带有通常被传递到end()可链接的已获取数据的响应对象,这显然是我所需要的.
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?
推荐答案
尽管您的问题是 GH ,我想也将其粘贴到其他位置.以下对我非常有用!
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'))
这篇关于将yield与superagent一起使用将返回请求对象而不是响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!