-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetData.js
35 lines (32 loc) · 845 Bytes
/
getData.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
const database = firebase.database();
async function getToken(user) {
const tokenRef = database.ref('users/qwe/key');
await tokenRef.get().then((snapshot) => {
if (snapshot.exists()) {
user["token"] = snapshot.val()["userToken"];
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
}
async function getNotice(user) {
const noticeRef = database.ref('users/qwe/notice/userNotice');
await noticeRef.get().then((snapshot) => {
if (snapshot.exists()) {
const data = JSON.parse(snapshot.val());
user["notice"] = data;
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
}
export async function getData() {
const user = {};
await getToken(user);
await getNotice(user);
return user;
}