fix integration

This commit is contained in:
2025-06-05 21:40:30 +02:00
parent 3bd3b9b70d
commit 48cf5cd6c4
9 changed files with 92 additions and 33 deletions

View File

@@ -1,10 +1,15 @@
import axios from "axios";
import {useAuthStore} from "@/store/authStore";
const API_URL = "https://testowe.zikor.pl/api/v1";
export async function listCategories() {
const { token } = useAuthStore.getState();
const headers = token ? { 'Authorization': `Bearer ${token}` } : {};
try {
const response = await axios.get(`${API_URL}/vars/categories`);
const response = await axios.get(`${API_URL}/vars/categories`, { headers });
return response.data;
} catch (err) {
console.error("Nie udało się pobrać listy kategorii.", err.response.status);

View File

@@ -2,9 +2,9 @@ import axios from "axios";
import FormData from 'form-data'
import {useAuthStore} from "@/store/authStore";
// const API_URL = "https://testowe.zikor.pl/api/v1";
const API_URL = "https://testowe.zikor.pl/api/v1";
const API_URL = "http://10.0.2.2:8080/api/v1";
//const API_URL = "http://10.0.2.2:8080/api/v1";
export async function listNotices() {
const { token } = useAuthStore.getState();

View File

@@ -1,14 +1,16 @@
import axios from "axios";
import {useAuthStore} from "@/store/authStore";
// import FormData from 'form-data'
const API_URL = "https://testowe.zikor.pl/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}`, null, {
headers: {
"Content-Type": "application/json",
},
const response = await axios.post(`${API_URL}/toggle/${noticeId}`, {}, {
headers
});
return response.data;
} catch (error) {
@@ -18,8 +20,11 @@ export async function toggleNoticeStatus(noticeId) {
}
export async function getWishlist() {
const { token } = useAuthStore.getState();
const headers = token ? { 'Authorization': `Bearer ${token}` } : {};
try {
const response = await axios.get(`${API_URL}/`);
const response = await axios.get(`${API_URL}/`, {headers});
console.log("Wishlist response:", response.data);
return response.data;
} catch (error) {