I am currently facing an issue while trying to console.log the documents from my Firebase real-time database. When attempting this, I encounter the following error:
[Vue warn]: Error in created hook: "TypeError: firebase__WEBPACK_IMPORTED_MODULE_2__.default.database(...).get is not a function"
Is there a way for me to successfully log all the docs stored in the database?
Below is what I have tried so far:
<script>
import firebase from "firebase";
const db = firebase.database();
export default {
name: "Login",
data() {
return {
user: {
email: "",
password: "",
},
};
},
methods: {
userLogin() {
firebase
.auth()
.signInWithEmailAndPassword(this.user.email, this.user.password)
.then(() => {
this.$router.push("/");
})
.catch((error) => {
alert(error.message);
});
},
},
created() {
firebase
.database()
.get()
.then((snapshot) => {
snapshot.forEach((doc) => {
console.log(doc.data());
});
});
},
};
</script>