Answer the question
In order to leave comments, you need to log in
How to get data through Nuxt template?
In the nuxt template (default) I try to write a request to the json file via axios, but the data does not come on the network (f12 - network). Tell me how to fix this?
<v-navigation-drawer v-model="rightDrawer" :right="right" temporary fixed nav>
<perfect-scrollbar>
<ProjectBarList :projects="projects" />
</perfect-scrollbar>
</v-navigation-drawer>
const URL_PROJECTS = '~/../files/json/projects.json'
export default {
async asyncData({ $axios }) {
const getProjectList = async () => {
try {
const res = await $axios.$get(URL_PROJECTS)
return res
} catch (e) {
} finally {
}
}
const projects = await getProjectList()
return {
projects
}
}
}
Answer the question
In order to leave comments, you need to log in
asyncData only works on page components
data() {
return {
projects: []
}
}
async fetch() {
this.projects = await this.$axios.$get(URL_PROJECTS)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question