Home

Issue: 1018

How to deal with multiple dynamic routes nuxt generate

[issue link]

Hey, in nuxt guide there is example how to deal with dynamic routes using promise and call to axios, now, how to deal with two of them?

generate: {
    routes: function (callback) {
      let posts = axios.get('https://api.com/posts', {params: {size: 10}}).then((res) => {
        return res.data.posts.map((post) => {
          return '/feed/' + post.id
        })
      })
      let users = axios.get('https://api.com/users', {params: {size: 10}}).then((res) => {
        return res.data.users.map((user) => {
          return '/user/' + user.id
        })
      })
      let route = Promise.all([posts, users]).then(values => {       
        return callback(null, route)
      })
    }
},

This is my example - trying to connect two promises but still have error.

This question is available on Nuxt.js community (#c884)