rsnext/examples/with-vercel-fetch/pages/index.js
Michael McQuade 5032dd926a
Change zeit fetch to vercel fetch (#21913)
This PR does the following:

- Update documentation referencing @zeit/fetch to @vercel/fetch
- Switch packages @zeit/fetch to @vercel/fetch
- ~~Fix `browser.js` to actually use @vercel/fetch, it was only using unfetch directly before~~
- Update React to 17 
- Change folder name and package name
2021-02-18 15:09:52 +00:00

21 lines
501 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Link from 'next/link'
import fetch from '../fetch'
export default function Index({ stars }) {
return (
<div>
<p>Next.js has {stars} </p>
<Link href="/preact">
<a>How about preact?</a>
</Link>
</div>
)
}
export async function getStaticProps() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const json = await res.json() // better use it inside try .. catch
return {
props: { stars: json.stargazers_count },
}
}