-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.js
42 lines (39 loc) · 1.24 KB
/
functions.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
36
37
38
39
40
41
42
/*===================================================================//
VERSION 8 (current)
//===================================================================*/
import { functions } from "./init-firebase";
// Call a function
const addData = functions.httpsCallable("addData");
const callAddDataFunction = async () => {
await addData({ data: "some-data" })
.then((result) => {
const data = result.data;
return data;
})
.catch((error) => {
const { code, message, details } = error;
console.log(code);
console.log(message);
console.log(details);
});
};
/*===================================================================//
VERSION 9 (beta)
//===================================================================*/
import { functions } from "./init-firebase";
import { httpsCallable } from "firebase/functions";
// Call a function
const addData = httpsCallable(functions, "addData");
const callAddDataFunction = async () => {
await addData({ data: "some-data" })
.then((result) => {
const data = result.data;
return data;
})
.catch((error) => {
const { code, message, details } = error;
console.log(code);
console.log(message);
console.log(details);
});
};