-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposts.js
59 lines (42 loc) · 1.74 KB
/
posts.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyBM_3brfuZeGxa2ESW7peV1L5arpErRcP0",
authDomain: "norman-b1fa4.firebaseapp.com",
projectId: "norman-b1fa4",
storageBucket: "norman-b1fa4.appspot.com",
messagingSenderId: "554557044751",
appId: "1:554557044751:web:2e4acb2576eee924974b7a"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// Initialize Cloud Firestore and get a reference to the service
const db = firebase.firestore();
const section = document.getElementById('section')
//const message = document.getElementById('message')
//const date = document.getElementById('date')
section.innerHTML = "";
db.collection("blackoutInfo").get().then((querySnapshot) => {
querySnapshot.forEach((doc) => {
// doc.data() is never undefined for query doc snapshots
//console.log(doc.id, " => ", doc.data().email);
const heading = doc.data().heading;
const message = doc.data().message;
const date = doc.data().date;
// Create a new paragraph element for each email and append it to the container
const headings = document.createElement("h3");
const messages = document.createElement("p");
const dates = document.createElement("span")
headings.textContent = heading;
messages.textContent = message
dates.textContent= `Expected date ${date}`
section.appendChild(headings);
section.appendChild(messages);
section.appendChild(dates);
});
});
const deleteButton = document.getElementById('delete')
db.collection("cities").delete().then(() => {
console.log("Document successfully deleted!");
}).catch((error) => {
console.error("Error removing document: ", error);
});