首页 > 解决方案 > Firebase - 单击按钮时在云功能中运行“functions.https”

问题描述

是否可以通过单击 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`);
});

标签: firebasegoogle-cloud-functionsfirebase-hosting

解决方案


是的,它是可调用函数,请看:https ://firebase.google.com/docs/functions/callable


推荐阅读