简体   繁体   中英

Cloud Functions .onCall() unable to return data

I have merged three Observables via pipe() and then I'm converting it to a Promise so I can return it. I have tested the call with onRequest() and it works just fine. However with onCall() I keep getting this error:

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

I have tried a lot of things but all of them return the same error. Am I doing something wrong here?

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})
});

Swift

functions.httpsCallable("getNotifications").call() { (result, error) in
    if let error = error as NSError? {
        print(error)
    }

    print(result?.data) // nil
}

So somehow onCall() is not supported in europe-west1 . I removed the region and it works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM