1
votes

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.

2
firebaser here Answer on how to fix this is below. But can you tell me where you got that config snippet from? I get the correct URL in my tests and if this is a bug I'd love to get it fixed.Frank van Puffelen
I got the config from firebase except for the databaseURL which I added afterwards.milmal
Hmmm... then where did you get that specific URL value from? Thanks for answering btw, as you're not the only one to have problems here.Frank van Puffelen

2 Answers

2
votes

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.

-2
votes

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