Answer the question
In order to leave comments, you need to log in
How to generate pages in Nuxt based on api response results?
Has a folder structure
pages
| index.vue
| posts
| | index.vue
| | _post.vue
nuxt generate
that, I get one index.html in the posts folder Answer the question
In order to leave comments, you need to log in
I myself will answernuxt.config.js
generate: {
routes: async function () {
/* получить список постов, у которых есть свойство postname */
const { data: posts } = await axios.get('https://mydomain/posts');
/* вернуть массив адресов вида '/posts/%postname%' */
return posts.map(u => `/posts/${u.postname}`);
}
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question