fix login check and urls
This commit is contained in:
@@ -1,34 +1,38 @@
|
||||
import axios from "axios";
|
||||
import {useAuthStore} from "@/store/authStore";
|
||||
import { useAuthStore } from "@/store/authStore";
|
||||
// import FormData from 'form-data'
|
||||
|
||||
const API_URL = "https://testowe.zikor.pl/api/v1/wishlist";
|
||||
const API_URL = "https://hopp.zikor.pl/api/v1/wishlist";
|
||||
|
||||
export async function toggleNoticeStatus(noticeId) {
|
||||
const { token } = useAuthStore.getState();
|
||||
const headers = token ? { 'Authorization': `Bearer ${token}` } : {};
|
||||
const { token } = useAuthStore.getState();
|
||||
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
||||
|
||||
try {
|
||||
const response = await axios.post(`${API_URL}/toggle/${noticeId}`, {}, {
|
||||
headers
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error toggling wishlist item:", error);
|
||||
throw error;
|
||||
}
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${API_URL}/toggle/${noticeId}`,
|
||||
{},
|
||||
{
|
||||
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}` } : {};
|
||||
const { token } = useAuthStore.getState();
|
||||
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${API_URL}/`, {headers});
|
||||
console.log("Wishlist response:", response.data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching wishlist:", error);
|
||||
throw error;
|
||||
}
|
||||
try {
|
||||
const response = await axios.get(`${API_URL}/`, { headers });
|
||||
console.log("Wishlist response:", response.data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching wishlist:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user