I have a Vue app where I initialize my firestore app. My code looks like the following:
if (firebase.apps.length) {
firebase.app()
} else {
firebase.initializeApp(config)
}
export const Firestore = firebase.firestore()
export const Auth = firebase.auth()
Now I would like to bring the config file from some API. Which mean, instead of doing firebase.initializeApp(config) I would like to do something like:
axios.get('https://.../config.json', {})
.then(async ({ data }) => {
firebase.initializeApp(data)
})
.catch((err) => {
console.log('error', err)
})
But my exports will have to wait till I get the response from the API and init the app.
How can I make the exports wait with async/await or any other pattern?