From 338f10dc897b720c4ef50925f32e34638328c29e Mon Sep 17 00:00:00 2001 From: Qin Guan Date: Sat, 23 Sep 2023 12:28:33 +0800 Subject: [PATCH] fix: fix --- server/api/user/[id].post.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/api/user/[id].post.ts b/server/api/user/[id].post.ts index 6983b59..419c968 100644 --- a/server/api/user/[id].post.ts +++ b/server/api/user/[id].post.ts @@ -17,7 +17,7 @@ export default defineProtectedEventHandler(async (event) => { const { data } = result - const user = await event.context.database.update(users) + const updatedUsers = await event.context.database.update(users) .set({ firebaseId: data.firebaseId, }) @@ -26,7 +26,14 @@ export default defineProtectedEventHandler(async (event) => { ) .returning() - return user + if (updatedUsers.length === 1) { + throw createError({ + status: 500, + statusMessage: 'Internal server error', + }) + } + + return updatedUsers[0] }, { allowUnlinkedUser: true, })