Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

364
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda