Hello I'm doing a project shcool on nodeJS and work with firebase.
I try to get the name of a users to not rewrite an existing value.
the db is:
my code to try something:
serv.js
const firebaseConfig = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTHDOMAIN,
databaseURL: process.env.REACT_APP_DATABASEURL,
projectId: process.env.REACT_APP_PROJECTID,
storageBucket: process.env.REACT_APP_STORAGEBUCKET,
messagingSenderId: process.env.REACT_APP_MESSASGINGSENDERID,
appId: process.env.REACT_APP_APPID,
measurementId: process.env.REACT_APP_MEASUREMENTID
};
const {initializeApp} = require('firebase/app');
const {getDatabase} = require('firebase/database');
const {getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword} = require('firebase/auth');
const fireapp = initializeApp(firebaseConfig);
const db = getDatabase(fireapp);
var firebaseauth = getAuth(fireapp);
[...]
function create_entry_name(name, email)
{
const ref = db.ref('/users/' + name);
ref.on('value', (snapshot) => {
console.log(snapshot.val());
}, (errorObject) => {
console.log('The read failed: ' + errorObject.name);
});
}
that's litteraly the example on the firebase website.
But I get an error witch is:
db.ref is not a function
I will really be thanks full if you have an solution for this problem...

dbproperly? Try console logging it and see if it is what you expect.db, I consoled log him but that doesn't give me a clue... @insyri