Ekran logowania i rejestracja działa! Tylko wewnętrzne logowanie, bez google
This commit is contained in:
0
ArtisanConnect/api/auth.jsx
Normal file
0
ArtisanConnect/api/auth.jsx
Normal file
@@ -1,12 +1,21 @@
|
||||
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://172.20.10.2:8080/api/v1";
|
||||
const API_URL = "http://10.0.2.2:8080/api/v1";
|
||||
|
||||
export async function listNotices() {
|
||||
const response = await fetch(`${API_URL}/notices/get/all`);
|
||||
const { token } = useAuthStore.getState();
|
||||
const headers = token ? { 'Authorization': `Bearer ${token}` } : {};
|
||||
|
||||
console.log(token);
|
||||
|
||||
const response = await fetch(`${API_URL}/notices/get/all`, {
|
||||
headers: headers
|
||||
});
|
||||
console.log(response);
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(response.toString());
|
||||
@@ -17,11 +26,11 @@ export async function listNotices() {
|
||||
export async function getNoticeById(noticeId) {
|
||||
const response = await fetch(`${API_URL}/notices/get/${noticeId}`);
|
||||
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error("Error");
|
||||
}
|
||||
return data;
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error("Error");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function createNotice(notice) {
|
||||
|
||||
Reference in New Issue
Block a user