Files
smugglers-run/app/components/apitest.tsx
T
2026-02-07 15:33:25 +01:00

20 lines
656 B
TypeScript

// app/Apitest.tsx
export default async function Apitest() {
// 1. Fetch the data directly in the component
const res = await fetch('https://swapi.py4e.com/api/people/1/');
const data = await res.json();
// 2. This console.log will appear in your TERMINAL, not the browser console
// because this is a Server Component!
console.log("Fetched Pilot:", data.name);
return (
<div className="p-4 border border-yellow-500 rounded-md bg-black/20">
<h2 className="text-xl font-bold text-yellow-400">Smuggler Intel</h2>
<p>Name: {data.name}</p>
<p>Height: {data.height}cm</p>
<p>Mass: {data.mass}kg</p>
</div>
);
}