首页 > 解决方案 > 如何使用“firebase 函数:shell”调用 HTTPS 函数?

问题描述

我不明白如何在本地调用 HTTPS 函数。

我制作了 index.js 文件并导出了hello函数并运行firebase functions:shell.

我阅读了这份文件,并按照以下方式进行操作:

https://firebase.google.com/docs/functions/local-shell#invoke_https_functions

# invoke
myHttpsFunction()
myHttpsFunction.get()
myHttpsFunction.post()

但我收到了这条信息hello is not defined

这是我写的 index.js。

const admin = require('firebase-admin')
const {https} = require('firebase-functions')

admin.initializeApp()

exports.hello = https.onRequest((_, response) => {
  response.end('hello')
})

这是终端。

$ firebase functions:shell
✔  functions: Using node@8 from host.
✔  functions: Emulator started at http://localhost:5001
i  functions: Watching "/Users/xxx/xxx" for Cloud Functions...
⚠  Default "firebase-admin" instance created!
i  functions: HTTP trigger initialized at http://localhost:5001/xxx/us-central1/hello
i  functions: HTTP trigger initialized at http://localhost:5001/xxx/us-central1/callable
firebase > ⚠  Default "firebase-admin" instance created!
firebase > hello()
ReferenceError: hello is not defined

> firebase > hello()应该是return hello,但是hello is not defined

标签: firebasegoogle-cloud-functionsfirebase-cli

解决方案


这是 Firebase CLI 模拟器中的一个错误。请关注 GitHub 上的问题。现在,请遵循该问题中的此建议

将来,也可以在那里发布错误报告。关于错误报告,Stack Overflow 没有太多帮助。


推荐阅读