Nuxt/examples/new-fetch/nuxt.config.js
2020-02-04 19:36:22 +01:00

19 lines
414 B
JavaScript

const fetch = require('node-fetch')
export default {
plugins: [
'@/plugins/vue-placeholders.js'
],
modules: [
'@nuxt/http'
],
generate: {
async routes () {
const posts = await fetch('https://jsonplaceholder.typicode.com/posts').then(res => res.json()).then(d => d.slice(0, 20))
const routes = posts.map(post => `/posts/${post.id}`)
return ['/'].concat(routes)
}
}
}