0
votes

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) => {..}
1
Please edit the question to provide the complete, minimal code needed to reproduce this. stackoverflow.com/help/minimal-reproducible-exampleDoug Stevenson
@DougStevenson I just added sample codeEduardo
Your sample code doesn't declare firebase, so it doesn't look complete to me. Also I'm not sure why you would require firebase-funcitons without doing something with the object it returns. You need that to build your Cloud Function defintion.Doug Stevenson
Forgot to copy first line, my bad.Eduardo

1 Answers

1
votes

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.