Having an issue where the map is not displaying my items after an api call.
export default async function LoginPage() {
const res = await fetch("http://127.0.0.1:3000/api/machines");
if (!res.ok) {
throw new Error("Failed to fetch machine data");
}
const machines = await res.json();
console.log(machines.data);
return (
<main>
<h1>Login Page</h1>
<p>Testing...</p>
{machines.data.map((machine: any) => {
<p>{machine.name}</p>;
})}
</main>
);
}
it displays everything up to Testing… and doesn’t include the machine data map.
I tried outputting the machine data in the map and was expecting it to display on screen.
New contributor
Achtepa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.