9

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

1 Answer 1

21

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

Sign up to request clarification or add additional context in comments.

3 Comments

a "-" not / is seems const functions = require('firebase-functions');
For those who are loading from CDN, include corresponding Firebase JS SDKs. For example, if firebase.functions() is undefined, then include firebase-functions.js from CDN as documented here firebase.google.com/docs/web/setup#libraries_CDN
If using ES6 use this: import 'firebase/functions'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.