If you use a "standard" HTTPS Cloud Function, you need to issue an HTTP request from your Web page, with JavaScript. One way to do that is by using the axios library.
It is quite simple:
You declare the library in the head part of your html page
<head>
...
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
...
</head>
And, in your JavaScript code, you call the Cloud Function through its URL. Here is an example with a POST Request:
axios.post('https://us-central1-<project-id>.cloudfunctions.net/<your-cloud-cunction-name>', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
//Do whatever you wantwith the response object, returned by the HTTPS Cloud Function
})
.catch(function (error) {
console.log(error);
});
In the Cloud Function you would do req.body.firstName
and req.body.lastName
to get the values passed in the body of the POST Request. If you don't need to pass values through the request's body, you may use a GET method (and possibly pass some values through Query String).
If you want, in the Cloud Function, to use the 'busboy' library to parse a 'multipart/form-data'
upload request (as shown in the example you refer to in your question) the following Stack Overflow answer explains how to do it with axios:
axios post request to send form data
Note that Firebase offers another type of HTTP Cloud Function: the HTTPS Callable Functions.
With this type you can call it from your web front-end using the dedicated Cloud Functions client library provided by Firebase. The documentation shows the following example:
var addMessage = firebase.functions().httpsCallable('addMessage');
addMessage({text: messageText}).then(function(result) {
// Read result of the Cloud Function.
var sanitizedMessage = result.data.text;
// ...
});
Have a look at the doc, which explains all the steps (how to write the Cloud Function and how to call it) into detail.