init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import axios from "axios";
|
||||
import { useAuthStore } from "../store/authStore";
|
||||
|
||||
const API_URL = "/api/v1/wishlist";
|
||||
|
||||
export async function toggleNoticeStatus(noticeId) {
|
||||
const { token } = useAuthStore.getState();
|
||||
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${API_URL}/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 axios.get(`${API_URL}/`, { headers: headers });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching wishlist:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user