Firebase-单击按钮时在云函数中运行“ functions.https”

时间:2018-11-15 23:29:49

标签: firebase google-cloud-functions firebase-hosting

是否可以通过单击HTML中的按钮来使Firebase云功能运行?

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`);
});

1 个答案:

答案 0 :(得分:2)

是的,可以调用的函数看一下:https://firebase.google.com/docs/functions/callable