Files
frontend/src/api/wishlist.js
T

33 lines
857 B
JavaScript

import { useAuthStore } from "../store/authStore";
import api from "./api";
export async function toggleNoticeStatus(noticeId) {
const { token } = useAuthStore.getState();
const headers = token ? { Authorization: `Bearer ${token}` } : {};
try {
const response = await api.post(
`/wishlist/toggle/${noticeId}`,
{},
{ headers: headers }
);
return response.data;
} catch (error) {
console.error("Error toggling wishlist item:", error);
throw error;
}
}
export async function getWishlist() {
const { token } = useAuthStore.getState();
const headers = token ? { Authorization: `Bearer ${token}` } : {};
try {
const response = await api.get(`/wishlist/`, { headers: headers });
return response.data;
} catch (error) {
console.error("Error fetching wishlist:", error);
throw error;
}
}