![](/img/trans.png)
[英]Firebase Cloud Functions: Transactions function not returning promise?
[英]Returning a promise of multiple async functions in a firebase cloud function?
所以我有一个Firebase云功能,可以调用2个异步功能。
exports.someFunction = functions.firestore
.document('some/path')
.onCreate(event => {
asyncFunction1();
asyncFunction2();
});
asyncFunction1和asyncFunction2都返回一个promise。
现在, Firebase决定我们应该这样做
通过返回JavaScript承诺来解析执行异步处理的函数(也称为“后台函数”)。
但是,由于我的函数正在执行两个异步进程,我应该返回什么? 我试过了
exports.someFunction = functions.firestore
.document('some/path')
.onCreate(event => {
return Promise.all(
asyncFunction1(),
asyncFunction2()
);
});
这有效:两个函数都被正确调用和执行,但我也得到错误TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined at Function.all
在调用Cloud函数时, TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined at Function.all
。
有任何想法吗? 提前致谢。
您可以尝试Promise.all([asyncFunction1(), asyncFunction2()])
。 看看链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.