Skip to content

Instantly share code, notes, and snippets.

@isilveira1
Last active June 15, 2022 09:51
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 isilveira1/a6b649e3f5a64bf668e24918bcaf2131 to your computer and use it in GitHub Desktop.
Save isilveira1/a6b649e3f5a64bf668e24918bcaf2131 to your computer and use it in GitHub Desktop.
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