Set functions’ region depending on whether emulator or live

Image for post
Image for post
Photo by Roman Kraft on Unsplash

the ‘functionsRegion’ method returns a value depending on whether it is under an emulator or live server.

If you ser your region somewhere, not default region (us-central1), you have to set a region when you call functions like this.

But if you call your localhost function, you have to rid of the region parameter, and call the function ‘useFunctionsEmulator’ before to call functions

c.f.

useFunctionsEmulator is now deprecated in the latest version of Firebase SDK. Check the document.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store