-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.js
More file actions
34 lines (28 loc) · 848 Bytes
/
Copy pathrequest.js
File metadata and controls
34 lines (28 loc) · 848 Bytes
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
import { ref, child, get, set, update } from "firebase/database";
import { database } from "./firebase-config";
const dbRef = ref(database);
export const getApi = async (option) => {
const res = await get(child(dbRef, option));
return res.val();
};
export const setApi = async (option, content = {}) => {
set(child(dbRef, option), content);
};
export const updateApi = async (option, content = {}) => {
update(child(dbRef, option), content);
};
// get(child(dbRef, `users`))
// .then((snapshot) => {
// if (snapshot.exists()) {
// console.log(snapshot.val());
// } else {
// console.log('No data available');
// }
// })
// .catch((error) => {
// console.error(error);
// });
// // set(child(dbRef, `users/2`), {
// // id: 2,
// // name: 'aaa',
// // });