Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2017 18:23
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 anonymous/7cb34e83acff0442324feaee0b7341ea to your computer and use it in GitHub Desktop.
Save anonymous/7cb34e83acff0442324feaee0b7341ea to your computer and use it in GitHub Desktop.
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