According to Firebase's documentation, the following code can be used to call a onCall function named addMessage.
var addMessage = firebase.functions().httpsCallable('addMessage');
addMessage({text: messageText}).then(function(result) {
// Read result of the Cloud Function.
var sanitizedMessage = result.data.text;
})
I have a function named test, with the following code in Javascript (just to test this functionality):
exports.test = functions.https.onCall((data, context) => {
console.log(data);
data.page++;
console.log(data);
var testing = firebase.functions().httpsCallable('test');
while(data.page < 5) {
testing({page: data.page}).then(res => {
console.log("done");
})
}
});
When running this, however, I get the following error:
Unhandled error TypeError: firebase.functions is not a function
What am I doing wrong?