In my Vue app, I've set up my firestore app initialization code as shown below:
if (firebase.apps.length) {
firebase.app()
} else {
firebase.initializeApp(config)
}
export const Firestore = firebase.firestore()
export const Auth = firebase.auth()
Now, I want to fetch the config file from an API. Instead of directly calling `firebase.initializeApp(config)`, I aim to do something like this:
axios.get('https://.../config.json', {})
.then(async ({ data }) => {
firebase.initializeApp(data)
})
.catch((err) => {
console.log('error', err)
})
However, I need to ensure that my exports wait until I receive the response from the API and initialize the app.
Is there a way to achieve this by using async/await or any other pattern?