import { useState } from "react"; import axios from "axios"; function ProjectSearch() { const [projectId, setProjectId] = useState(""); const [project, setProject] = useState(null); const [error, setError] = useState(""); const fetchProject = async () => { try { setError(""); const res = await axios.get(`http://localhost:8000/projects/${projectId}`); setProject(res.data); } catch (err) { setProject(null); setError("Project not found"); } }; return (
{error}
} {project && (ID: {project.id}
Name: {project.name}
Description: {project.description}