import axios from 'axios'

export default {
  getRoutes: async () => {
    // We can fetch any data we want, however we want!
    const { data: posts } = await axios.get('https://jsonplaceholder.typicode.com/posts')
    return [
      {
        path: 'blog',
        getData: () => ({
          posts,
        }),
        children: posts.map(post => ({
          path: `blog/post/${post.id}`,
          component: 'Post',
          data: {
            post,
          },
        })),
      },
    ]
  },
}
