Search code examples
firebasegoogle-cloud-functionsfirebase-hosting

Firebase - run "functions.https" in a cloud function when button clicked


Is it possible to get a firebase cloud function to run from clicking a button in HTML?

html

<html>
    <head>
      <title>My Title</title>
    </head>
    <body>
      This is some content
      <button onclick="exports.testName('testTxt')">click test</button>

    </body>
</html>

index.js

const functions = require('firebase-functions');

exports.testName = functions.https.onRequest((req, res) => {

  res.status(200).send(`New Content`);
});

Solution

  • Yes it's call callable function look at this: https://firebase.google.com/docs/functions/callable