Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!