[Vuejs]-How to wait for api call on js export?

1👍

You can just do:

export const initialize = () => {
 try {
   return axios.get('https://.../config.json', {})
    } catch(err) {
      console.log('error', err)
    }
  }

And then in another js file, you can first import it and then do the following:

initialize().then(data => {
firebase.initializeApp(data)
firebase.firestore()
}).catch((err) => {
    console.log(err);
});

There is no point to export firebase.firestore(), since you are going to be calling it in every js file if you want to use firestore.

The only method that you really need to export is firebase.initializeApp(data) which you can add it inside the method initialize() and return it

Leave a comment