-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import Acesso from '@/components/acesso'; | ||
import ServerFetch from '@/components/server-fetch'; | ||
|
||
export default function HomePage() { | ||
return ( | ||
<main> | ||
<h1>Home</h1> | ||
<Acesso /> | ||
<ServerFetch /> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import dynamic from 'next/dynamic'; | ||
const Width = dynamic(() => import('@/components/width'), { ssr: false }); | ||
import ClientFetch from '@/components/client-fetch'; | ||
|
||
export default function SobrePage() { | ||
return ( | ||
<main> | ||
<h1>Sobre</h1> | ||
<Width /> | ||
<ClientFetch /> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
|
||
type Produto = { | ||
id: number; | ||
nome: string; | ||
}; | ||
|
||
export default function ClientFetch() { | ||
const [data, setData] = React.useState<Produto[]>([]); | ||
|
||
React.useEffect(() => { | ||
async function fetchData() { | ||
const response = await fetch('https://api.origamid.online/produtos'); | ||
const json = (await response.json()) as Produto[]; | ||
setData(json); | ||
} | ||
fetchData(); | ||
}, []); | ||
|
||
return ( | ||
<ul> | ||
{data.map((produto) => ( | ||
<li key={produto.id}>{produto.nome}</li> | ||
))} | ||
</ul> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
type Produto = { | ||
id: number; | ||
nome: string; | ||
}; | ||
|
||
export default async function ServerFetch() { | ||
const response = await fetch('https://api.origamid.online/produtos'); | ||
const data = (await response.json()) as Produto[]; | ||
|
||
return ( | ||
<ul> | ||
{data.map((produto) => ( | ||
<li key={produto.id}>{produto.nome}</li> | ||
))} | ||
</ul> | ||
); | ||
} |