Fixed bugs in removeUser api

This commit is contained in:
Peter KW 2024-03-28 12:38:12 +01:00
parent 50042ded41
commit 3d9bd2ef96

View file

@ -186,19 +186,17 @@ export const api: API = {
): Promise<APIResponse<User>> { ): Promise<APIResponse<User>> {
try { try {
const response = await fetch(`/api/userdelete/${username}`, { const response = await fetch(`/api/userdelete/${username}`, {
method: "POST", method: "DELETE",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Authorization: "Bearer " + token, Authorization: "Bearer " + token,
}, },
body: JSON.stringify(username), body: JSON.stringify(username),
}); });
if (!response.ok) { if (!response.ok) {
return { success: false, message: "Failed to remove user" }; return { success: false, message: "Could not remove user" };
} else { } else {
const data = (await response.json()) as User; return { success: true };
return { success: true, data };
} }
} catch (e) { } catch (e) {
return { success: false, message: "Failed to remove user" }; return { success: false, message: "Failed to remove user" };