next-app/app/page.tsx

24 lines
578 B
TypeScript
Raw Normal View History

2024-06-01 09:38:11 +03:00
import Image from "next/image";
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
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>
);
}