function showNotes(){
let html = "";
let notesElm = document.getElementById('notes');
get(child(dbRef,"Notes")).then((snapshot) => {
var count = 0
if (snapshot.exists()) {
const noteData = snapshot.val()
for (const item in noteData) {
if (Object.hasOwnProperty.call(noteData, item)) {
const element = noteData[item];
html+=`
<div class="card mx-2 my-2 noteCard" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">${element.title}</h5>
<p class="card-text">${element.text}</p>
<button id=${count} onclick="deleteElement(${element.title})" class="btn btn-primary">Delete Node</button>
</div>
</div>
`;
}
count++
}
notesElm.innerHTML = html;
} else {
console.log("No data available");
}
}).catch((error) => {
console.error(error);
});
}
function deleteElement(item){
remove(ref(db,"Notes/"+item))
.then(()=>{
console.log("Data has been removed")
})
.catch((err)=>{
console.log(err);
})
window.location.reload()
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)