Firebase CDN
links:
https://www.gstatic.com/firebasejs/7.14.0/firebase-app.js
https://www.gstatic.com/firebasejs/7.14.0/firebase-auth.js
https://www.gstatic.com/firebasejs/7.14.0/firebase-firestore.js
https://www.gstatic.com/firebasejs/7.14.0/firebase-analytics.js
// Authentication with Email
const auth = fireabase.auth()
auth.createUserWithEmailAndPassword(email, password).then(cred => {
console.log(cred);
});
auth.signOut().then(() => console.log('user signed out));
auth.signInWithEmailAndPassword(email, password).then(cred => {
console.log(cred);
})
auth.onAuthStateChanged(user => {
// fired when login, sign in or logout
// and if user if null then user is not logged in..
}
// Firestore
const db = firebase.firestore();
db.collection('collection_name').get().then(snapshots => {
console.log(snapshots.docs);
});
db.collection('collection_name').add(fields here...).then(() => {
console.log('data added...');
});
//this onShapshot allow us to set real-time listener to our database if theirs change in the database it will give us new data...
db.collection('collection_name').onSnapshot(snapshots => {
console.log(snapshots.docs)
});