Last active
May 25, 2019 12:03
-
-
Save Auwalms/11e27226e48634b9f2eb18e96c0e03f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
/** | |
* the config object contains secrets needed for identification and interaction | |
* with firebase/firestore. | |
* ALWAYS STORE THIS SECRETS IN A PROTECTED FILE AND DON'T SEND IT TO YOUR REPOSITORY. | |
* THIS METHOD IS ONLY USED IN THE CASE OF AN OPTION PROJECT LIKE THIS | |
*/ | |
const config = { | |
apiKey: "AIzaSyBcd5WmLL4Bwyh1cj0zkbHcBp8LZLg_rMY", | |
databaseURL: "https://auwsum-kitchen.firebaseio.com", | |
projectId: "auwsum-kitchen" | |
}; | |
firebase.initializeApp(config); | |
const db = firebase.firestore(); | |
const categoriesRef = db.collection("categories"); | |
const getCategories = () => { | |
showLoading(); | |
categoriesRef | |
.get() | |
.then(categories => { | |
for (let category of categories.docs) { | |
if (categoriesContainer) { | |
categoriesContainer.append( | |
createCategoryHTML(category.data()) | |
); | |
} | |
} | |
hideLoading(); | |
}) | |
.catch(error => { | |
console.error(error); | |
hideLoading(); | |
}); | |
}; | |
function showLoading() { | |
document.getElementById("circle").removeAttribute("class"); | |
} | |
function hideLoading() { | |
document.getElementById("circle").setAttribute("class", "hidden"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment