Closed folamy closed 5 years ago
What you are looking for is described at https://v1.quasar-framework.org/quasar-cli/cli-documentation/boot-files#Accessing-data-from-boot-files
I know about boot files..... but, since there is no access to ‘this.$axios..get() in prefetch()’ , what I’m looking for something like (nuxtjs asyncdata(context ){}), in which you can do context.axios.get(....) context.$storyblok.get(...)
@folamy You're looking at this the wrong way. There's an example in docs with Axios that you can take a look at: https://v1.quasar-framework.org/quasar-cli/cli-documentation/boot-files#Axios
If you're using the preFetch
option, you have access to the store which is sufficient in order to dispatch some actions such as initial data load.
However, if you're using axios
, you have to make sure that it receives the full path e.g. http://example.com/v1/get/initalData
instead of just /v1/get/initialData
. Otherwise you'll get a connect ECONNREFUSED 127.0.0.1:80
error (see SO)
Alternatively, you can use the proxy
setting of axios
in order to avoid using the full path.
[v1] I think it would be better if axios and any other registered plugins in boot can access in prefetch like this
preFetch ({ axios, store,......ssrContext }) { axios.get('/test')...... }