Я не понимаю, как вызывать 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
.