简体   繁体   中英

Firebase database is throwing "Firebase error. Please ensure that you spelled the name of your Firebase correctly"

I'm trying to push an object to the firebase database, but the push() method isn't working and it seems likely it has something to do with the warning I'm getting:

@firebase/database:, FIREBASE WARNING: Firebase error. Please ensure that you spelled the name of your Firebase correctly (https://<DATABASE_NAME>.firebaseio.com)

However it matches databaseURL in the config I have in the App.js

const config = {
apiKey: "<...>",
authDomain: "<...>.firebaseapp.com",
projectId: "<...>",
storageBucket: "<...>.appspot.com",
messagingSenderId: "<...>",
appId: "<...>",
databaseURL: "https://<...>.firebaseio.com",
};
firebase.initializeApp(config);

The method I use to get access to the database:

 const { currentUser } = firebase.auth();
 console.log(currentUser.uid); // works fine
 firebase
     .database()
     .ref(`/users/${currentUser.uid}/cards`)
     .push({some object})

I'm using Database location: Belgium (europe-west1) if that matters. And firebase authentication works fine.

The databaseURL in your configuration snippet does not seem to match the actual URL of your database.

I recommend getting the correct URL from the Firebase console and putting that in the config.

In my case, realtime databse wasn't created yet. I faced this issue for below code on react app.

set(ref(db,'users/' + userid), {
  username:name,
  email:email,
  profile_picture: uploadLink
})

Above syntax for writing to realtime database not firestore

This error shows up when we create a database in Cloud database. Actually, we need to create a real time database which provides databaseURL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM