rsnext/examples/api-routes-rest/pages/index.js
Joe Haddad 18a9c7e371
Improve linting rules to catch more errors (#9374)
* Update `packages/`

* Update examples

* Update tests

* Update bench

* Update top level files

* Fix build

* trigger
2019-11-10 19:24:53 -08:00

23 lines
484 B
JavaScript

import fetch from 'isomorphic-unfetch'
import Link from 'next/link'
const Index = ({ users }) => (
<ul>
{users.map(user => (
<li key={user.id}>
<Link href="/user/[id]" as={`/user/${user.id}`}>
<a>{`User ${user.id}`}</a>
</Link>
</li>
))}
</ul>
)
Index.getInitialProps = async () => {
const response = await fetch('http://localhost:3000/api/users')
const users = await response.json()
return { users }
}
export default Index