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

227
Visualizações
Get Firebase child value in JavaScript

I want to only get a specific child value from Firebase using JavaScript. I always get the entire child values.

This is what it looks like:

Child a -
        |- fcmToken: 'abcdefg'

Child a -
        |- fcmToken: 'hijklmn'

I always get the entire thing. "Child a – fcmToken: 'abcdefg'" But I only want to get the fcmToken value 'abcdefg' and 'hijklmn'

Ho can I do so?

I tried this:

return admin.database().ref('/fcmToken').once('value', snapshot => {

var uid = snapshot.val();

return admin.database().ref('/fcmToken/' + uid).once('value', snapshot => {

  var fcmToken = snapshot.val();
  console.log('FCMTOKEN:', fcmToken)

});

But it's not working. Any ideas, how I can only get the desired values 'abcdefg' and 'hijklmn'

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After days of trying I have finally found a solution! Here is what I did:

return admin.database().ref('/fcmToken').once('child_added', snapshot => {

var uid = snapshot.key;

return admin.database().ref('/fcmToken/' + uid + '/fcmToken').once('value', snapshot => {

  var fcmToken = snapshot.val();

});

The var fcmToken = snapshot.val(); was the data, I needed and was trying to get.

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