javascript - Cloud Functions .onCall() 无法返回数据
问题描述
我已经合并了三个 Observable pipe()
,然后我将它转换为 Promise,以便我可以返回它。我已经用它测试了这个电话,onRequest()
它工作得很好。但是,随着onCall()
我不断收到此错误:
错误域 = NSCocoaErrorDomain 代码 = 3840 “JSON 文本没有以数组或对象开头,并且允许未设置片段的选项。” UserInfo={NSDebugDescription=JSON 文本没有以数组或对象开头,并且允许未设置片段的选项。}
我已经尝试了很多东西,但它们都返回相同的错误。我在这里做错了吗?
export const getNotifications = functions.region('europe-west1').https.onCall((data, context) => {
const notificationsObs = rxjs.from(db.collection('notifications').where('receiverID', '==', 'jmwJLofoKpaQ4jligJKPc24UEe72').get());
const requestObs = (requestsRef: any) => rxjs.from(db.getAll(...requestsRef));
const packageObs = (packagesRef: any) => rxjs.from(db.getAll(...packagesRef));
const notifications: Notification[] = [];
return notificationsObs.pipe(
mergeMap(snapshot => {
//
return requestObs(requestsRef);
}),
mergeMap((requests) => { // kthen requests
//
return packageObs(packagesRef)
})
).toPromise().then(() => {
return { notifications: "test" };
}).catch(err => {err})
});
迅速
functions.httpsCallable("getNotifications").call() { (result, error) in
if let error = error as NSError? {
print(error)
}
print(result?.data) // nil
}
解决方案
所以不知何故onCall()
不支持europe-west1
。我删除了该区域,它工作正常。
推荐阅读
- angular - 如何以角度获取表格中选定的行值?
- java - Primefaces 6.2 PhotoCam - Firefox / Safari 的网络摄像头错误
- swift - 尝试快速停止计时器对象时出现致命错误
- python - 启动 dask.distributed Client/LocalClient 后无法捕获 KeyboardInterrupt 异常
- android - Cordova:自适应图标显示前景图像,但不显示背景颜色
- mongodb - Apache Drill - 首次启动时间较长
- c - 从现有 C 文件、头文件和 makefile 创建 Visual Studio 项目
- mongodb - 带有 upsert false 的 Mongo updateOne 不起作用?
- php - 匹配数据并使用 IF 语句打印数据
- python - 在 python 中使用 mysql 连接器从 mysql 数据库中正确获取 blob