Debug Functions locally
run the emulator
We may run the functions on their own or all emulators.
npm run serve
firebase emulators:start --only functions
firebase emulators:start --import=./saved --export-on-exit
connect the client to the emulator
we opt-in to use the emulated cloud functions:
connectFunctionsEmulator(functions, "localhost", 5001)
connect a shell to the emulator
The command starts the emulator and connects a CLI REPL shell session to it so that we may trigger the functions from the CLI:
firebase functions:shell
npm run shell # alternative
call a Callable function from the CLI: we add the request's payload to the mandatory data property.
requestArticles({ data: { name: "Lena" } })
make direct HTTP requests to the emulated functions
The URL follows a specific pattern
http://localhost:5001/imgtale/europe-west1/request_articles
curl -s -H "Content-Type: application/json" \
-d '{ "data": { } }' \
http://localhost:5001/imgtale/europe-west1/request_articles