To call locally runs firebase emulators:start --only function
check the function name you want to call at functions list http://localhost:4001/functions
.
await fetch('<HTTP-LOCAL-URL-YOU-PICKED-FROM-THE-LIST>', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({data:{ /* YOUR JSON COMES HERE */ }})
});
To call remotely
await fetch('http://us-central1-<MY_PROJECT_NAME>.cloudfunctions.net/<MY_FUNCTION_NAME>', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({data:{ /* YOUR JSON COMES HERE */ }})
});
It will ping your backend local and remote respectively.