Skip to content

Instantly share code, notes, and snippets.

@isilveira1
Last active June 15, 2022 09:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
const Doggo: NextPage = ({ dog }) => {
...
};
// This function gets called at build time
export const getStaticProps: GetStaticProps = async () => {
// Call an external API endpoint to get a dog
const res = await fetch("https://.../dogs/a-doggo");
const dog = await res.json();
// By returning { props: { dog } }, the Doggo component
// will receive `dog` as a prop at build time
return {
props: {
dog,
},
};
}
export default Doggo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment