2024-06-01 09:38:11 +03:00
|
|
|
import Image from "next/image";
|
|
|
|
|
2024-06-01 11:06:08 +03:00
|
|
|
async function getData() {
|
|
|
|
const res = await fetch('https://my-json-server.typicode.com/typicode/demo/posts');
|
|
|
|
// The return value is *not* serialized
|
|
|
|
// You can return Date, Map, Set, etc.
|
|
|
|
|
|
|
|
if (!res.ok) {
|
|
|
|
// This will activate the closest `error.js` Error Boundary
|
|
|
|
throw new Error('Failed to fetch data');
|
|
|
|
}
|
|
|
|
|
|
|
|
return res.json()
|
|
|
|
}
|
2024-06-01 09:38:11 +03:00
|
|
|
|
2024-06-01 11:06:08 +03:00
|
|
|
export default async function Home() {
|
|
|
|
const data = await getData();
|
|
|
|
return (
|
|
|
|
<main>
|
|
|
|
<p className = "text-lg font-sans hover:text-xl">{ data[ 1 ].title } </p>
|
2024-06-01 09:38:11 +03:00
|
|
|
</main>
|
|
|
|
);
|
|
|
|
}
|