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

196
Visualizações
Firebase push get key with sdk 9 modular approach

As the question asks I'm attempting to get the key after I push to a firebase db.

 push(dbRef, formState)
 .then((resp) => {
   console.log(resp);
 })
 .catch(error => {
   Alert.alert(error)
 })

The above console.log gives me the full url of the data pushed. In example:

"https://example.firebaseio.com/organization/asdfasdfasdf/members/-N08ScImBoOckVIRu-AU". I need the key only: `-N08ScImBoOckVIRu-AU`

I incorrectly attempted:

 push(dbRef, formState)
 .getKey()
 .then((resp) => {
 })
 .catch(error => {
   Alert.alert(error)
 })

This gives an error. How can I accomplish this?

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

0

If you split the push() call from the actual writing of the data, you can get the key like this:

const newRef = push(dbRef);
console.log(newRef.key);
set(newRef, formState);
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