Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

363
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda