I have a Nuxt project that is built upon an external headless API (JSON), which feeds content to the application. When I try to run npm run generate, Nuxt will create a dist folder with all routes in a folder and fills each of them with an index.html file. However these HTML files are not filled with any content that originates from the API. The expected behavior is that I am able to see statically generated content.
Is somebody able to tell me why prerendering my application doesn't work? I suspect something is wrong with my nuxt.config.js:
generate: {
routes() {
// Routes from headless CMS
const pages = axios.get(`${api}/routes.json`).then((res) => {
return res.data.data.map((item) => {
return item.route
})
})
// External API with vacancies
const vacancies = axios
.get('https://api.external.website')
.then((res) => {
return res.data.jobs.map((item) => {
return '/careers/vacancies/' + item.id
})
})
// Combine both routes
return Promise.all([pages, vacancies]).then((values) => {
return [...values[0], ...values[1]]
})
}
}