如何使用“ firebase functions:shell”调用HTTPS函数?

时间:2019-05-12 19:28:14

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

我不知道如何在本地调用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()应该返回hello,但返回hello is not defined

1 个答案:

答案 0 :(得分:0)

这是Firebase CLI模拟器中的错误。请follow the issue on GitHub。目前,follow this advice in that issue

将来,也会在此发布错误报告。在错误报告方面,堆栈溢出没有什么可以帮助您的。