import { Component } from 'react' import Head from 'next/head' import fetch from 'isomorphic-unfetch' import Post from '../components/post' export default class extends Component { static async getInitialProps () { // fetch list of posts const response = await fetch('https://jsonplaceholder.typicode.com/posts?_page=1') const postList = await response.json() return { postList } } render () { return (
Home page

List of posts

{this.props.postList.map(post => )}
) } }