ADD: Introduce API client and update axios usage across the application

This commit is contained in:
2026-04-27 15:44:07 +02:00
parent a847a8768d
commit 599fb59f24
10 changed files with 102 additions and 74 deletions
+4 -6
View File
@@ -1,15 +1,13 @@
import axios from "axios";
import { useAuthStore } from "../store/authStore";
const API_URL = "/api/v1/wishlist";
import api from "./api";
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}`,
const response = await api.post(
`/wishlist/toggle/${noticeId}`,
{},
{ headers: headers }
);
@@ -25,7 +23,7 @@ export async function getWishlist() {
const headers = token ? { Authorization: `Bearer ${token}` } : {};
try {
const response = await axios.get(`${API_URL}/`, { headers: headers });
const response = await api.get(`/wishlist/`, { headers: headers });
return response.data;
} catch (error) {
console.error("Error fetching wishlist:", error);