Skip to content

Instantly share code, notes, and snippets.

@Auwalms
Last active May 25, 2019 12:03
Show Gist options
  • Save Auwalms/11e27226e48634b9f2eb18e96c0e03f3 to your computer and use it in GitHub Desktop.
Save Auwalms/11e27226e48634b9f2eb18e96c0e03f3 to your computer and use it in GitHub Desktop.
"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