rsnext/examples/data-fetch/pages/preact-stars.js
Luis Alvarez D 333a9ea8ab
Documentation updates (#16503)
Fixes https://github.com/vercel/next.js/issues/16502

Check the issue for more details.
2020-08-24 02:23:12 +00:00

25 lines
473 B
JavaScript

import Link from 'next/link'
function PreactStars({ stars }) {
return (
<div>
<p>Preact has {stars} </p>
<Link href="/">
<a>I bet Next.js has more stars (?)</a>
</Link>
</div>
)
}
export async function getStaticProps() {
const res = await fetch('https://api.github.com/repos/developit/preact')
const json = await res.json()
return {
props: {
stars: json.stargazers_count,
},
}
}
export default PreactStars