Compare commits
2 Commits
cbea96f892
...
61363cc400
| Author | SHA1 | Date | |
|---|---|---|---|
| 61363cc400 | |||
| 885ad40543 |
@@ -8,7 +8,7 @@
|
||||
|
||||
let userName = $state('')
|
||||
let userPassword = $state('')
|
||||
let userList = $state([])
|
||||
let userList: { userId: string; userName: string }[] = $state([])
|
||||
let addUserError = $state(false);
|
||||
let addUserSuccess = $state(false);
|
||||
const currentUser: string = data.user.id;
|
||||
@@ -65,7 +65,7 @@
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
async function deleteUser(userId: number) {
|
||||
async function deleteUser(userId: string) {
|
||||
const URL = `/api/users/${userId}`;
|
||||
|
||||
const response = await fetch(URL, {
|
||||
|
||||
@@ -19,6 +19,11 @@ export async function POST({ request, locals }) {
|
||||
const data = await request.json();
|
||||
const userName = data.userName;
|
||||
const userPassword = data.userPassword;
|
||||
|
||||
if (!userName || !userPassword) {
|
||||
return json({ error: 'Missing input' }, { status: 400 });
|
||||
}
|
||||
|
||||
const rowCount = addUser(userName, userPassword);
|
||||
|
||||
return new Response(null, { status: rowCount == 1 ? 200 : 400 });
|
||||
|
||||
Reference in New Issue
Block a user