Ad

How Can I Call HTTPS Function With 'firebase Functions:shell'?

I don't understand how to call HTTPS functions in local.

I made index.js file and exported hello functions and run firebase functions:shell.

I read this document, and I followed this way:

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

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

but I got this message hello is not defined

This is index.js I wrote.

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

admin.initializeApp()

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

This is terminal.

$ firebase functions:shell
✔  functions: Using [email protected] 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() should be return hello, but hello is not defined.

Ad

Answer

This is a bug in the Firebase CLI emulator. Please follow the issue on GitHub. For now, follow this advice in that issue.

In the future, post bug reports there as well. There is not much Stack Overflow can help you with in regards to bug reports.

Ad
source: stackoverflow.com
Ad