communication from client to nuxt server

This commit is contained in:
2024-01-22 19:43:20 +01:00
parent bc1a80b53e
commit 2a4dc80efa
2 changed files with 73 additions and 3 deletions

15
server/api/login.ts Normal file
View File

@ -0,0 +1,15 @@
export default defineEventHandler(async (event) => {
const body = await readBody(event)
if ((body.username == 'test') && (body.password == 'asd')) {
setResponseStatus(event, 202)
return {
login: 'successful'
}
} else {
throw createError({
statusCode: 400,
statusMessage: 'Login failed',
})
}
})