Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud functions with firebase: firebase.functions is not a function

After creating a cloud function addMessage on Firebase using Firebase SDK 4.12.0, the following code does not work when attempting to call the addMessage function from within my client app:

var firebase = require("../node_modules/firebase")
var functions = firebase.functions();

functions.httpsCallable("addMessage").call(
    //...
)

TypeError: firebase.functions is not a function

like image 303
B. Jack Avatar asked Mar 25 '18 20:03

B. Jack


People also ask

What are Cloud Functions in Firebase?

Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your JavaScript or TypeScript code is stored in Google's cloud and runs in a managed environment.

Is Cloud Functions free in Firebase?

Cloud Functions includes a perpetual free tier for invocations to allow you to experiment with the platform at no charge. Note that even for free tier usage, we require a valid billing account.

What types of Cloud Functions exist?

There are two types of Cloud Functions: HTTP functions, which handle HTTP requests and use HTTP triggers. See Write HTTP functions for information about implementing HTTP functions. Event-driven functions, which handle events from your cloud environment and use event triggers as described in Cloud Functions triggers.

How do I run a Firebase function?

The Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. To call a function from your app in this way, write and deploy an HTTPS Callable function in Cloud Functions, and then add client logic to call the function from your app.


1 Answers

The solution was to add require("firebase/functions")

like image 111
B. Jack Avatar answered Oct 18 '22 22:10

B. Jack