Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

356
Views
How to delete an item in firebase realtime Database when clicking a button?

I am making a table that shows me data from some sensors, this table shows the data from a database hosted in firebase. As data is entered, the table will display. I'm having trouble deleting the data because for each item that is inserted, I've put an id in it so I can identify it as follows:

enter image description here

enter image description here

Each of the elements in the table has its own button to delete, whose id is the same as the database element: enter image description here

To delete the data, what I'm doing is that clicking the button takes the value of the button id, adding it to the URL of the database path, sending a DELETE request:

async function reply_click(clicked_id){
  var bid = clicked_id;
  var firebase = "https://iotplatform-11dca-default-rtdb.firebaseio.com/users/awsBewgkSMcqiINzOoFUiUe9D6r1/data_widget/sensor/humedad/temperatura/";
  var json = ".json";
  var url = firebase+bid+json;
  console.log(url);
  const request = new Request(url, { method: 'DELETE'})
  const response = await fetch(request)
  return await response.json()
} 

I printed the url obtained to check that it is correct but the data is not deleted. After an undefined time or without knowing that I have moved it, the data is automatically deleted leaving everything in null.

I hope you have explained me well and you can help me

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This snippet will remove the child follow the documentation carefully

https://firebase.google.com/docs/database/web/read-and-write

initRef = firebase.database().ref('users/awsBewgkSMcqiINzOoFUiUe9D6r1/data_widget/sensor/humedad/temperatura/');

function deleteIssue(id) {
  initRef.child(`${id}`).remove();
  console.log('child removed oncliking button '+ id );
  
  
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!