mon-site-perso/frontend/app/projects/page.tsx

36 lines
No EOL
1,014 B
TypeScript

async function getProjects() {
const baseUrl = process.env.BACKEND_URL;
if (!baseUrl) {
throw new Error("Variable d'environnement BACKEND_URL manquante");
}
const res = await fetch(`${baseUrl}/projects/`, {
cache: "no-store",
});
if(!res.ok){
throw new Error("Erreur lors de la récupération des projets depuis l'API");
}
return res.json();
}
export default async function ProjectsPage() {
const projects = await getProjects();
return(
<section id="projets" className="section">
<div className="container">
<h2 className="section-title">Mes projets</h2>
<ul className="projects-list">
{projects.map((p: any) => (
<li key={p.id}>
<h3>{p.name}</h3>
<p>{p.description}</p>
</li>
))}
</ul>
</div>
</section>
);
}