firebase - 如何使用“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
。
解决方案
这是 Firebase CLI 模拟器中的一个错误。请关注 GitHub 上的问题。现在,请遵循该问题中的此建议。
将来,也可以在那里发布错误报告。关于错误报告,Stack Overflow 没有太多帮助。
推荐阅读
- php - 解析错误:语法错误,文件意外结束,期待 '`'
- python - 使用矢量化时如何跳过前 n 行
- java - 我应该创建一个对象列表还是更改我的界面?
- python - 如何有条件地沿numpy ndarray的特定轴在特定位置设置值
- java - 为什么 java Arrays.binarySearch 返回奇怪的结果?
- google-sheets - Google 服务帐户无法使用 gspread 编辑/更新 Google 表格
- blazor - 如何制作 matblazor RTL(从右到左)
- swift - 如何在 swiftUI 中的父视图中运行
- php - PHP 将条件附加到准备好的语句
- asp.net-core - Core 3.0 ApplicationUser 始终为空