Created
April 7, 2017 18:23
-
-
Save anonymous/7cb34e83acff0442324feaee0b7341ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Layout from '../components/Layout'; | |
import axios from 'axios'; | |
class SSRTest extends React.Component { | |
static async getInitialProps ({req}) { | |
const response = await axios.get('https://jsonplaceholder.typicode.com/users'); | |
return { | |
users: response.data | |
} | |
} | |
render() { | |
const { users } = this.props; | |
const userList = users.map( | |
user => <li key={user.id}>{user.username}</li> | |
) | |
return ( | |
<Layout> | |
<ul> | |
{userList} | |
</ul> | |
</Layout> | |
); | |
} | |
} | |
export default SSRTest; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment