~5 years in web development
Technical Director @ Page Design Group
3-time instructor @ UCD Coding Bootcamp
Favorite Languages: JavaScript, php, Go
Twitter: @treighton1988 // GitHub: @treighton
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.
Layout, Fetching JSON, and passing to Components
import React from 'react'
import Layout from '../components/Layout'
import Articles from '../components/Articles'
import fetch from 'isomorphic-unfetch'
const Index = (props) => {
return (
<Layout>
<Articles posts={props.posts} />
</Layout>
)
}
Index.getInitialProps = async function() {
const res = await fetch('http://pagedev.dev/wp-json/wp/v2/posts')
const data = await res.json()
console.log(data)
return {
posts: data
}
};
export default Index