0
code:
  const timeStamp = Math.floor(Date.now() / 1000);
        const insertKey =   "_" + timeStamp;
        const contactsDbRef = firebase.app().database().ref('contacts/');
        console.log(timeStamp+"/"+insertKey);
        contactsDbRef
             .child(insertKey)
            .set({
                
                name:name,
                number: number,
                email: email,
                
            },
            console.log("data added"),
                (error) => {
                    if (error) {
                        console.log(error)
                    } else {
                        
                        console.log("added successfully")
                       
                    }
                });
       
       

How do i store contact details of user in firebase in react native app?

It is console logging the data, however in the backend data is not reflecting

1
  • 1
    Do you get any errors? Commented Jun 22, 2021 at 13:18

1 Answer 1

1

I would suggest to try Firebase operations using promises and not error callbacks as in the docs.

const timeStamp = Math.floor(Date.now() / 1000);
const insertKey =   "_" + timeStamp;
        
const contactsDbRef = firebase.app().database().ref('contacts/'+insertKey);

contactsDbRef.set({
  name:name,
  number: number,
  email: email,
}).then(() => {
  console.log("Data updated")
}).catch(e => console.log(e))

I tried this out and worked perfectly. Let me know if the issue still persists.

Sign up to request clarification or add additional context in comments.

1 Comment

No sir, "Data updated" is also not coming in console and data is not adding in database. It would be great if you also attach screenshot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.