2 Commits

2 changed files with 7 additions and 2 deletions

View File

@@ -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, {

View File

@@ -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 });