I'm new to firebase storage. I've been able to use firestore with documents using VUE, but I'm using storage for images.
I'm getting continual errors and I believe it relates to failing to create the reference as required.
Questions:
- Firebase storage requires a "ref" function. How do I import that per firebase documentation in a way that doesn't conflict with the vue "ref" function? My attempt is below, but it's not working.
- As currently set up below, I get an error 0 , firebase_config__WEBPACK_IMPORTED_MODULE_4_.storageRef) is not a function. I can't figure out how to overcome this--I keep going through documentation and reviewing videos, but I haven't figured it out yet.
Here is the config setup:
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import { getStorage, ref } from "firebase/storage";
const firebaseConfig = {
[Info]
};
// init firebase
initializeApp(firebaseConfig);
// init firestore service
const db = getFirestore();
// Get a reference to the storage service, which is used to
create references in your storage bucket
const storage = getStorage(initializeApp(firebaseConfig));
const storageRef = ref(storage);
export { db, storage, storageRef };
Here is the Vue setup:
import { computed, ref } from "vue";
//firebase imports
import { db, storage, storageRef } from
"../../firebase/config";
import { collection, getDocs } from "firebase/firestore";
import { getDownloadURL } from "firebase/storage";
export default {
name: "Name",
setup() {
const imagesRef = storageRef(storage);
getDownloadURL(imagesRef).then((url) => {
// Insert url into an <img> tag to "download"
console.log(url);
});