I'm making an app that counts the user-visiting number. I'm using vue.js 3 and firebase.
For now, I'm testing by sending data to firebase. But it has error"firebase.database is not a function" Can someone help this
import db from './db';
export default {
name: 'App',
methods:{
incrementNum(){
const numRef = db.database().ref("messages")
numRef.push('hi');
console.log('sent it')
},
},
}
The push() method returns a promise. Try an async method:
import db from './db';
export default {
name: 'App',
methods:{
async incrementNum() {
// ^^ async
const numRef = db.database().ref("messages")
await numRef.push('hi');
// ^^ await
console.log('sent it')
},
},
}