admin管理员组文章数量:1356768
So I have a Firebase Cloud Function that calls 2 async functions.
exports.someFunction = functions.firestore
.document('some/path')
.onCreate(event => {
asyncFunction1();
asyncFunction2();
});
Both asyncFunction1 and asyncFunction2 return a promise.
Now, Firebase dictates that we should
Resolve functions that perform asynchronous processing (also known as "background functions") by returning a JavaScript promise.
However, since my function is performing two asynchronous processes, what should I return? I tried doing
exports.someFunction = functions.firestore
.document('some/path')
.onCreate(event => {
return Promise.all(
asyncFunction1(),
asyncFunction2()
);
});
This works: both functions get called and executed correctly, but I also get the error TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined at Function.all
when calling the Cloud Function.
Any ideas? Thanks in advance.
So I have a Firebase Cloud Function that calls 2 async functions.
exports.someFunction = functions.firestore
.document('some/path')
.onCreate(event => {
asyncFunction1();
asyncFunction2();
});
Both asyncFunction1 and asyncFunction2 return a promise.
Now, Firebase dictates that we should
Resolve functions that perform asynchronous processing (also known as "background functions") by returning a JavaScript promise.
However, since my function is performing two asynchronous processes, what should I return? I tried doing
exports.someFunction = functions.firestore
.document('some/path')
.onCreate(event => {
return Promise.all(
asyncFunction1(),
asyncFunction2()
);
});
This works: both functions get called and executed correctly, but I also get the error TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined at Function.all
when calling the Cloud Function.
Any ideas? Thanks in advance.
Share Improve this question asked Mar 2, 2018 at 12:37 Daniel ValderramaDaniel Valderrama 3411 gold badge3 silver badges13 bronze badges1 Answer
Reset to default 12You can try Promise.all([asyncFunction1(), asyncFunction2()])
. Look on link
本文标签: javascriptReturning a promise of multiple async functions in a firebase cloud functionStack Overflow
版权声明:本文标题:javascript - Returning a promise of multiple async functions in a firebase cloud function? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743980231a2571050.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论