--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/68e6b4b5-fe74-45df-a523-6ab6939c83b6n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/a29d007d-9091-4ffd-95f0-d4521cffb4f6n%40googlegroups.com.
Hi Sam,
I’m using Quasar for Vuejs which imports the Firebase settings from a boot file. I then import the Firebase objects into my Vuejs components and don’t modify it anywhere else.
Here’s the entire boot file followed by snippets from the JavaScript code . As you can see I’m using environment variables for the config settings.
import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'
import 'firebase/functions'
import 'firebase/storage'
// FIREBASE CONFIG
const firebaseConfig = {
apiKey: process.env.firebaseConfig.apiKey,
authDomain: process.env.firebaseConfig.authDomain,
databaseURL: process.env.firebaseConfig.databaseURL,
projectId: process.env.firebaseConfig.projectId,
storageBucket: process.env.firebaseConfig.storageBucket,
messagingSenderId: process.env.firebaseConfig.messagingSenderId,
appId: process.env.firebaseConfig.appId,
measurementId: process.env.firebaseConfig.measurementId
}
// Initialize Firebase Performance Monitoring.
// firebase.performance() TO-DO: Figure out how to include performance monitoring
const firebaseApp = firebase.initializeApp(firebaseConfig)
const firebaseAuth = firebaseApp.auth()
const firebaseFunctions = firebaseApp.functions()
const firebaseStore = firebaseApp.firestore()
const Timestamp = firebase.firestore.Timestamp
const Fieldvalue = firebase.firestore.Fieldvalue
const storage = firebase.storage()
// Use emulators
if (window.location.hostname === 'localhost') {
firebaseStore.useEmulator("localhost", 8080)
firebaseFunctions.useEmulator("localhost", 5001)
firebaseAuth.useEmulator('http://localhost:9099')
}
// *** Use Firebase server
firebaseStore.settings({
// ssl: false,
ignoreUndefinedProperties: true
})
firebase.firestore().enablePersistence()
.catch(function (error) {
if (error.code === 'failed-precondition') {
console.log('persistence failed-precondition')
} else if (error.code === 'unimplemented') {
console.log('persistence unimplemented')
}
})
export {
firebaseAuth,
firebaseFunctions,
firebaseStore,
Timestamp,
Fieldvalue,
storage
}
import { firebaseStore } from 'boot/firebase'
export default {
name: 'PageTest',
data () {
return {
}
},
components: {
},
methods: {
async getUser () {
try {
const userID = 'MFMBgLxkVZN8YXuHNs2Dx2LSs3y2'
const docRef = firebaseStore.collection("users").doc(userID);
docRef.get().then((doc) => {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
console.log("No such document!");
}
}).catch((error) => {
console.log("Error getting document:", error);
});
console.log(doc)
} catch (error) {
alert('error', `Error getting user info, error: ${error}`)
this.usersLoaded = true
}
},
}
}
Roger Hopkins
To view this discussion on the web visit
https://groups.google.com/d/msgid/firebase-talk/CAHafJBo3h0rWRW5L4bZL9eOYf_WPLxem_uFrYkha0r39_5T5Mw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/DS7PR10MB4880F5F9CF2671171B732F0EA6039%40DS7PR10MB4880.namprd10.prod.outlook.com.
Thanks Sam!
That did it (the bulleted solution).
To view this discussion on the web visit
https://groups.google.com/d/msgid/firebase-talk/CAHafJBq%3DU5SQdFDKj28_313Lhhcwk4OR0ANMnc90Ycbo%2B40a1g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/DS7PR10MB4880CC8423492D163EC3A375A6019%40DS7PR10MB4880.namprd10.prod.outlook.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/DS7PR10MB4880CC8423492D163EC3A375A6019%40DS7PR10MB4880.namprd10.prod.outlook.com.