【问题标题】:Cloud Functions .onCall() unable to return dataCloud Functions .onCall() 无法返回数据
【发布时间】:2020-04-03 20:28:01
【问题描述】:

我通过pipe() 合并了三个 Observable,然后我将其转换为 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
}

【问题讨论】:

    标签: javascript node.js firebase rxjs google-cloud-functions


    【解决方案1】:

    所以europe-west1 不支持onCall()。我删除了该区域,它工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-15
      • 2022-01-08
      • 2019-10-13
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      相关资源
      最近更新 更多