Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user