Reputation: 1831
I am trying to set a region to deploy my functions. According to the documentation I have to do:
var functions = firebase.app().functions('us-west2');
But when I do this and then try to deploy I get an error:
Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'onCall' of undefined
If I change functions definitions back to default:
const functions = require("firebase-functions");
It works, any ideas why I get this error?
Sample Code: const firebase = require("firebase"); const admin = require("firebase-admin"); require("firebase-functions");
firebase.initializeApp({...})
admin.initializeApp()
let functions = firebase.app().functions('us-east1')
exports.findUserInAuth = functions.https.onCall((data, context) => {..}
Upvotes: 1
Views: 533
Reputation: 317402
I think you're reading the documentation incorrectly.
If this is a most basic definition of a callable function, as suggested by the documentation:
const functions = require("firebase-functions");
exports.findUserInAuth = functions.https.onCall((data, context) => {
// ...
});
Then, to change the region, you need to insert some more method calls in the builder for that function:
const functions = require("firebase-functions");
exports.findUserInAuth = functions.https.region('us-west2').onCall((data, context) => {
// ...
});
The code on the frontend client will not use firebase-functions. You have to use the instructions for setting up the client later on that page. Setting the region on the client works differently.
Upvotes: 1