changed urls

This commit is contained in:
2025-09-03 14:54:20 +02:00
parent b36f1ba9ba
commit d18465ff1d
2 changed files with 64 additions and 46 deletions

View File

@@ -54,14 +54,17 @@ export const createUser = async (
password: string password: string
) => { ) => {
try { try {
const response = await fetch(`https://backend.insta.the1s.de/api/createUser`, { const response = await fetch(
method: "POST", `https://backend.insta.the1s.de/api/createUser`,
headers: { {
"Content-Type": "application/json", method: "POST",
Authorization: `Bearer ${Cookies.get("token")}`, headers: {
}, "Content-Type": "application/json",
body: JSON.stringify({ username, role, password }), Authorization: `Bearer ${Cookies.get("token")}`,
}); },
body: JSON.stringify({ username, role, password }),
}
);
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to create user"); throw new Error("Failed to create user");
} }
@@ -74,14 +77,17 @@ export const createUser = async (
export const changePW = async (newPassword: string, username: string) => { export const changePW = async (newPassword: string, username: string) => {
try { try {
const response = await fetch(`http://localhost:8002/api/changePWadmin`, { const response = await fetch(
method: "POST", `https://backend.insta.the1s.de/api/changePWadmin`,
headers: { {
"Content-Type": "application/json", method: "POST",
Authorization: `Bearer ${Cookies.get("token")}`, headers: {
}, "Content-Type": "application/json",
body: JSON.stringify({ newPassword, username }), Authorization: `Bearer ${Cookies.get("token")}`,
}); },
body: JSON.stringify({ newPassword, username }),
}
);
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to change password"); throw new Error("Failed to change password");
} }
@@ -139,14 +145,17 @@ export const createItem = async (
can_borrow_role: number can_borrow_role: number
) => { ) => {
try { try {
const response = await fetch(`https://backend.insta.the1s.de/api/createItem`, { const response = await fetch(
method: "POST", `https://backend.insta.the1s.de/api/createItem`,
headers: { {
"Content-Type": "application/json", method: "POST",
Authorization: `Bearer ${Cookies.get("token")}`, headers: {
}, "Content-Type": "application/json",
body: JSON.stringify({ item_name, can_borrow_role }), Authorization: `Bearer ${Cookies.get("token")}`,
}); },
body: JSON.stringify({ item_name, can_borrow_role }),
}
);
if (!response.ok) { if (!response.ok) {
throw new Error("Failed to create item"); throw new Error("Failed to create item");
} }

View File

@@ -75,14 +75,17 @@ export const rmFromRemove = (itemID: number) => {
export const createLoan = async (startDate: string, endDate: string) => { export const createLoan = async (startDate: string, endDate: string) => {
const items = removeArr; const items = removeArr;
const response = await fetch("https://backend.insta.the1s.de/api/createLoan", { const response = await fetch(
method: "POST", "https://backend.insta.the1s.de/api/createLoan",
headers: { {
"Content-Type": "application/json", method: "POST",
Authorization: `Bearer ${Cookies.get("token") || ""}`, headers: {
}, "Content-Type": "application/json",
body: JSON.stringify({ items, startDate, endDate }), Authorization: `Bearer ${Cookies.get("token") || ""}`,
}); },
body: JSON.stringify({ items, startDate, endDate }),
}
);
if (!response.ok) { if (!response.ok) {
myToast("Fehler beim Erstellen der Ausleihe", "error"); myToast("Fehler beim Erstellen der Ausleihe", "error");
@@ -122,12 +125,15 @@ export const onReturn = async (loanID: number) => {
}; };
export const onTake = async (loanID: number) => { export const onTake = async (loanID: number) => {
const response = await fetch(`https://backend.insta.the1s.de/api/takeLoan/${loanID}`, { const response = await fetch(
method: "POST", `https://backend.insta.the1s.de/api/takeLoan/${loanID}`,
headers: { {
Authorization: `Bearer ${Cookies.get("token") || ""}`, method: "POST",
}, headers: {
}); Authorization: `Bearer ${Cookies.get("token") || ""}`,
},
}
);
if (!response.ok) { if (!response.ok) {
myToast("Fehler beim Ausleihen der Ausleihe", "error"); myToast("Fehler beim Ausleihen der Ausleihe", "error");
@@ -139,14 +145,17 @@ export const onTake = async (loanID: number) => {
}; };
export const changePW = async (oldPassword: string, newPassword: string) => { export const changePW = async (oldPassword: string, newPassword: string) => {
const response = await fetch("http://localhost:8002/api/changePassword", { const response = await fetch(
method: "POST", "https://backend.insta.the1s.de/api/changePassword",
headers: { {
"Content-Type": "application/json", method: "POST",
Authorization: `Bearer ${Cookies.get("token") || ""}`, headers: {
}, "Content-Type": "application/json",
body: JSON.stringify({ oldPassword, newPassword }), Authorization: `Bearer ${Cookies.get("token") || ""}`,
}); },
body: JSON.stringify({ oldPassword, newPassword }),
}
);
if (!response.ok) { if (!response.ok) {
myToast("Fehler beim Ändern des Passworts", "error"); myToast("Fehler beim Ändern des Passworts", "error");