Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolved bug in alumni #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/src/controllers/alumni.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ const getAllAlumni = asyncHandler(async (req, res) => {
.select("-__v");

if (!alumni || alumni.length === 0) {
throw new ApiError(404, "No alumni records found");
return res
.status(200) // Changed from 404 to 200 since it's not an error case
.json(new ApiResponse(200, [], "No Alumni Records Found"));
}

// Format the response for admin view
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/components/ShowAllAlumni.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ export default function AlumniTable() {
const response = await axios.get("/api/v1/alumni/all", {
withCredentials: true,
headers: {
'Content-Type': 'application/json',
// If you're using token in Authorization header
'Authorization': `Bearer ${localStorage.getItem('token')}` // adjust based on how you store the token
'Content-Type': 'application/json',
// If you're using token in Authorization header
'Authorization': `Bearer ${localStorage.getItem('token')}` // adjust based on how you store the token
}
});
});

if (response.data.success) {
setAlumniData(response.data.data);
} else {
setError("Failed to fetch alumni data.");
}
} catch (err) {
console.error("Error fetching alumni data:", err);
setError("An error occurred while fetching alumni data.");
console.error("Error fetching alumni data:", err.response?.data || err.message);
setError(err.response?.data?.message || "An error occurred while fetching alumni data.");
} finally {
setLoading(false);
}
Expand Down Expand Up @@ -161,8 +161,8 @@ export default function AlumniTable() {
{selectedWorkExperience.isCurrentlyWorking
? "Present"
: selectedWorkExperience.endDate
? new Date(selectedWorkExperience.endDate).toLocaleDateString()
: "N/A"}
? new Date(selectedWorkExperience.endDate).toLocaleDateString()
: "N/A"}
</p>
</div>
<button
Expand Down