'Not able to push data to real time database with react native

I am using this code to push to a real time database with NodeJS and this is working fine

import admin from "firebase-admin";


admin.initializeApp({
  credential: admin.credential.cert(process.env.GOOGLE_APPLICATION_CREDENTIALS),
  databaseURL: 'https://xxxxx1.firebasedatabase.app/'
});


var db = admin.database();
var ref = db.ref("queue");

ref.child('tasks').push({"id": "Some ID"}).then(function(){ process.exit();});

I want to push the same data within a react-native App. I tried the following code, but nothing is happening.

import database from '@react-native-firebase/database';

   const newReference = database().ref('queue')
    newReference.child('tasks').push({
      id: "Some ID"
    })

    const reference = database().ref('/queue/tasks').push();
    reference
      .set({
        id: "Some ID",
      })
      .then(() => console.log('Data updated.'));
      .catch(function(error) {
  //error callback
  console.log('Something went wrong ', error)

  })

The rules edited so that everyone can push in the database

{
  "rules": {
    ".read": true,
    ".write": true
  }
}


Solution 1:[1]

I found the problem. I missed this part in the documentation

NOTE: To get a reference to a database other than an 'us-central1' default database, you must pass the database URL. You can find your Realtime Database URL in the Realtime Database section of the Firebase console.

// firebase should be imported and not database
import { firebase } from '@react-native-firebase/database';

const reference = firebase
  .app()
  .database('https://<databaseName>.<region>.firebasedatabase.app/')
  .ref('/users/123');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user567