-
Notifications
You must be signed in to change notification settings - Fork 241
/
callable.js
35 lines (31 loc) · 1016 Bytes
/
callable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import firebase from "firebase/app";
import "firebase/functions";
function callAddMessage() {
const messageText = "Hello, World!";
// [START functions_call_add_message]
var addMessage = firebase.functions().httpsCallable('addMessage');
addMessage({ text: messageText })
.then((result) => {
// Read result of the Cloud Function.
var sanitizedMessage = result.data.text;
});
// [END functions_call_add_message]
}
function callAddMessageError() {
const messageText = "Hello, World!";
// [START functions_call_add_message_error]
var addMessage = firebase.functions().httpsCallable('addMessage');
addMessage({ text: messageText })
.then((result) => {
// Read result of the Cloud Function.
var sanitizedMessage = result.data.text;
})
.catch((error) => {
// Getting the Error details.
var code = error.code;
var message = error.message;
var details = error.details;
// ...
});
// [END functions_call_add_message_error]
}