如何使用 'firebase functions:shell' 调用 HTTPS 函数?
How Can I call HTTPS function with 'firebase functions:shell'?
我不明白如何在本地调用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
.
这是 Firebase CLI 模拟器中的错误。请follow the issue on GitHub. For now, follow this advice in that issue.
将来,post 错误报告也在那里。关于错误报告,Stack Overflow 无法为您提供太多帮助。
我不明白如何在本地调用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
.
这是 Firebase CLI 模拟器中的错误。请follow the issue on GitHub. For now, follow this advice in that issue.
将来,post 错误报告也在那里。关于错误报告,Stack Overflow 无法为您提供太多帮助。