[help][functions] Calling HTTP Functions from Android is failing [Error: Response is not valid JSON object.] #5439
-
Hello Everyone, I am using firebase functions on my mobile app, but somehow can't seem to connect to any firebase function. My firebase function looks like the following exports.testFunction = functions.region("europe-west3").https.onCall((data, context) => {
console.log("HERE")
return {
success: "Yes",
message: "HERE"
}
}) On react-native, I have the following call: functions()
.httpsCallable('testFunction')()
.then(response => {
console.log("Function response", response)
})
.catch(err => {
console.log("Function failed", err)
}); To connect to the import firebase from "@react-native-firebase/app"
firebase.app().functions('europe-west3') All my tries lead to the same error:
Additional note: The function is working perfectly using the web SDK on web browsers. Any help is appreciated My rnfirebase versions from package.json are: "@react-native-firebase/app": "^12.1.0",
"@react-native-firebase/auth": "^12.1.0",
"@react-native-firebase/crashlytics": "^12.1.0",
"@react-native-firebase/database": "^12.1.0",
"@react-native-firebase/functions": "^12.1.0",
"@react-native-firebase/storage": "^12.1.0",
"react": "16.13.1",
"react-native": "0.63.3", And I'm testing in an Android physical device (Xiaomi mi 8 with Android 10) Let me know if you need any other information and thank you for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
This is a function problem. Not sure why the web SDK doesn't flag it, but your function is not returning JSON in the way we expect. |
Beta Was this translation helpful? Give feedback.
This is a function problem. Not sure why the web SDK doesn't flag it, but your function is not returning JSON in the way we expect.
In particuar, double-quotes are not actually valid JSON are they? I wonder if it works with single quotes.
Here's a testing library of functions we know work, from the related FlutterFire project
https://github.com/FirebaseExtended/flutterfire/blob/master/.github/workflows/scripts/functions/src/index.ts