Skip to content

Commit

Permalink
Consumindo API na home
Browse files Browse the repository at this point in the history
Faz a requisição SSG.
  • Loading branch information
gioliveirass committed Apr 20, 2021
1 parent b0d049b commit eaba6fe
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion podcastrnext/SRC/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
export default function Home() {
export default function Home(props) {
return (
<h1>Index</h1>
)
}

export async function getStaticProps() {
const response = await fetch('http://localhost:3333/episodes')
const data = await response.json()

return {
props: {
episodes: data,
},
revalidate: 60 * 60 * 8, // A cada 8 horas (60*60*8) quando a página for acessada uma nova chamada API vai ser feita
}
}

0 comments on commit eaba6fe

Please sign in to comment.