Wait for async data in boot file
-
I have a single-page application which needs to get some configuration data from a json file, before the application can start. Things like api root and oauth configuration. This is needed because the same app runs on different environments, but with different configs.
In order to read the config file, I make an ajax fetch. But since this is asynchronous, the app starts before my data is ready.
How can I make my app wait for the config data, before it starts? -
In plain Vue, I would do something like this, in mains.js, to defer the Vue instantiation.
But Quasar does not give me access to modify main.jsfetch(’/config.json’).then(res => res.json()).then(config => {
new Vue({
data(){
return config
},
render: h => h(app)
}).mount(’#app’)
}) -
-
I am aware of boot files.
In a boot file, I can start fetching the config data, but I can’t wait for the response, so my app will continue starting up, before my config data are ready. -
-
Thank you @dobbel
I had missed the impact of using an async boot function. That did the trick. -
This post is deleted! -
Good to know that ‘trick’ works!