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

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

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 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