[javascript] code_firebase
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- useEffect(async() => {
- const getGymImages = async() => {
- const store_image_ref = ref(storage, `gs://fit-user-app/store_images/jP6AalbtPcjk0Lbcxo5q`);
- const fileReaderInstance = new FileReader();
- await list(store_image_ref).then(function(result) {
- result.items.forEach(async function (imageRef) {
- // And finally display them
- console.log(await getDownloadURL(imageRef));
- })
- }).catch(function(error) {
- // Handle any errors
- });
- /*
- fileReaderInstance.readAsDataURL(await (store_image_ref)).then(
- (x) => {
- fileReaderInstance.onload = () => {
- base64data = fileReaderInstance.result;
- setFitImage(base64data);
- }
- }
- )
- */
- }
- getGymImages()
- }, []);
- useEffect( async() => {
- const loadData = async() => {
- let fit_data = []
- db.collection('fitness_centres').get()
- .then(snapshot => {
- snapshot.forEach(doc=> async function(){
- const data = doc.data();
- data.id = doc.id
- })
- }).then(function(){
- setFitness(fit_data)
- setLoadedFitness(true)
- }
- ).catch(err => alert(err))
- }
- if (fitness.length == 0){
- await loadData()
- }
- }, [])
Editor
You can edit this paste and save as new: