title: Firebase: How to call an https.onCall function node.js?
body: <p>According to Firebase's documentation, the following code can be used to call a onCall function named <strong>addMessage</strong>.</p>
  
  <pre><code>var addMessage = firebase.functions().httpsCallable('addMessage');
  addMessage({text: messageText}).then(function(result) {
      // Read result of the Cloud Function.
      var sanitizedMessage = result.data.text;
  })
  </code></pre>
  
  <p>I have a function named <strong>test</strong>, with the following code in Javascript (just to test this functionality):</p>
  
  <pre><code>exports.test = functions.https.onCall((data, context) =&gt; {
    console.log(data);
    data.page++;
    console.log(data);
  
    var testing = firebase.functions().httpsCallable('test');
  
    while(data.page &lt; 5) {
      testing({page: data.page}).then(res =&gt; {
      console.log("done");
      })
    }
  });
  </code></pre>
  
  <p>When running this, however, I get the following error:</p>
  
  <blockquote>
    <p>Unhandled error TypeError: firebase.functions is not a function</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>