Overview
Marks a specific notification as read. Use this when the user views or acknowledges an individual notification.
Endpoint
PUT /api/notifications/:id/read
Request
Path parameters
The unique identifier of the notification to mark as read.
Response
A confirmation string indicating the notification was successfully marked as read.
Example
import { fetchWithAuth } from "./fetchWithAuth";
async function markNotificationAsRead(id: number): Promise<{ message: string }> {
const res = await fetchWithAuth(`/api/notifications/${id}/read`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
});
const data = await res.json();
if (!res.ok) {
throw new Error(data.error || "Failed to mark notification as read");
}
return data; // { message: string }
}