跳到主要内容
CNode

mongoose中的promise问题

问答
Yysj16发布于 11 年前最后回复 11 年前
651890

A .find() .then(fucntion(a){ console.log(a) return B.find() }) .then(function(b){ console.log(a); })

比如这样的代码,怎样能在第二个then中获取a的值

查看回复

回复 (6)

I
iamcc#611 年前

A.find B.find 都没有直接的联系,干嘛不用并行?Promise.all

Y
ysj16#511 年前
引用 i5ting@ysj16 no 还有别的办法

@i5ting 怎么用呀哥

I
i5ting#411 年前
引用 ysj16@i5ting 只能这样吗。。

@ysj16 no

还有别的办法

Promise.resolve(a,b)
Y
ysj16#311 年前
引用 i5ting

@i5ting 只能这样吗。。

I
i5ting#211 年前
var _a;

A
.find()
.then(fucntion(a){
_a =a
console.log(a)
return B.find()
})
.then(function(b){
console.log(a);
})

参与回复

登录后即可参与回复。登录