Fixed bugs in removeUser api
This commit is contained in:
parent
50042ded41
commit
3d9bd2ef96
1 changed files with 3 additions and 5 deletions
|
@ -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" };
|
||||||
|
|
Loading…
Reference in a new issue