matt000
matt000

Reputation: 133

React native firebase realtime database reference return null

I'm trying to use realtime database, but reference is returning null. Not working on ios and android.

database().ref('/users/123')
// returns "null/users/123"

If I do it like this, then it works. But you should not need to put the url of the database. It should find the default database ref.

const database = firebase.app().database(URL);

const reference = database.ref('/user/123');
// returns "URL/user/123"

Database location: Belgium (europe-west1)

"@react-native-firebase/app": "12.8.0", "@react-native-firebase/database": "12.8.0",

Upvotes: 0

Views: 504

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

For databases outside of the US (the original region) it is now recommended to specify the URL in code, instead of depending on it being read from the config file.

From the documentation:

To get a reference to a database other than a us-central1 default database, you must pass the database URL to getInstance() (or Kotlin+KTX database()) . For a us-central1 default database, you can call getInstance() (or database) without arguments.

Upvotes: 1

Related Questions