This is my code and it doesn't work it says that dbRef.remove()
is not a function.
DeleteData1.addEventListener('click',(e)=>{
var deleteCrop1 = document.getElementById('deleteCrop').value;
const dbRef = ref (database, 'Crops/'+deleteCrop1);
if(document.getElementById('deleteCrop').value == ''){
alert("Fields cannot be empty");
}else{
dbRef.remove();
alert("Data removed successfully")''
}
});
I tried using the docs in firebase but my code just doesn't work.
With the v9 SDK, there is no longer a remove()
method on a DatabaseReference object. Instead, you should use the remove()
function and pass the reference to it.
remove(dbRef)
.then(...)
.catch(...)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.