-
Notifications
You must be signed in to change notification settings - Fork 2
/
book.js
45 lines (36 loc) · 1.11 KB
/
book.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
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebaseApp.firestore();
const auth = firebaseApp.auth();
function savedata(){
const ratings = document.getElementById("ratings").value
console.log(ratings)
const title = document.getElementById("title").value
const review = document.getElementById("review").value
db.collection('review')
.add({
ratings: ratings,
title: title,
review: review
})
.then((docRef)=>{
console.log("Document written with ID: ", docRef.id)
alert("Review submitted")
})
.catch((error)=>{
console.log(error)
});
}
var titletext=document.getElementsByClassName("card-title");
var reviewtext=document.getElementsByClassName("card-text");
var i=0;
db.collection('review').get().then((querySnapshot)=>{
querySnapshot.docs.forEach((doc) =>{
var title=doc.data().title;
var review=doc.data().review;
titletext.item(i).innerText=title;
reviewtext.item(i).innerText=review;
i++;
})
}).catch((error)=>{
console.log(error);
});