Skip to content

Instantly share code, notes, and snippets.

@ivanoats
Created March 23, 2018 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanoats/e770576e18bd579d88d7d8c5d66abad2 to your computer and use it in GitHub Desktop.
Save ivanoats/e770576e18bd579d88d7d8c5d66abad2 to your computer and use it in GitHub Desktop.
// import fetch from 'node-fetch'
import axios from 'axios'
export default {
getSiteData: () => ({
title: 'React Static Large JSON test'
}),
getRoutes: async () => {
const { data: locations } = await axios.get(
'http://localhost:3001/locations',
{
headers: {
'Access-Control-Allow-Origin': '*'
}
}
)
return [
{
path: '/',
component: 'src/containers/Home'
},
{
path: '/about',
component: 'src/containers/About'
},
{
path: '/location',
component: 'src/containers/Blog',
getData: async () => ({
locations
}),
children: locations.map(location => ({
path: `/${location.id}`,
component: 'src/containers/Post',
getData: async () => ({
location
})
}))
},
{
is404: true,
component: 'src/containers/404'
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment