I'm deploying the following cloud function using firebase deploy --only functions :
export const testFunction = functions.https.onCall((data, context) => {
return {"data": "hello"};
});
and when call it from the client app using the code
var testFunction = firebase.functions().httpsCallable("testFunction");
testFunction().then((result) => {
// Read result of the Cloud Function.
this.data = result.data;
});
it works as expected. Now, I want to continue developing the function testing it on the local emulator so, following the documentation, I added this line to the web app code (before the function)
firebase.functions().useEmulator("localhost", 5001); // for local simulator
and I run the local emulator with:
firebase emulators:start --only functions
If I run the client app now, I correctly see the call going through the local emulator instead of the remote cloud function.
Problem: If modify the code the local function doesn't get updated. I need to run firebase deploy again in order to see the change in the response. How can I just deploy locally?
This stackoverflow solves the issue.
Solution in short:
After every change in your code, run npm run build to recomplie the code.
To auto-compile for every change in your code.
Change "build": "tsc" to "build": "tsc -w" in your package.json
file, and run the emulator in an another terminal window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With