From 74722ddfd6b21e43538a774f7d43e787d4e2794b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Thu, 4 Jan 2024 15:20:25 -0500 Subject: [PATCH] fix(api): update story editing route properly await `replaceOrUpdateContent` --- server/api/story/[id]/index.put.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/server/api/story/[id]/index.put.ts b/server/api/story/[id]/index.put.ts index df46765..f19ca92 100644 --- a/server/api/story/[id]/index.put.ts +++ b/server/api/story/[id]/index.put.ts @@ -9,13 +9,7 @@ import { countWords } from "@functions"; import { messages } from "@server/constants"; export default eventHandler(async (ev) => { - let os: - | (Document & - IStory & - Required<{ - _id: number; - }>) - | null = await storyQuerier(ev); + let os: (Document & IStory) | null = await storyQuerier(ev); isLoggedIn(ev); if (!canModify(ev, os)) { throw createError({ @@ -52,7 +46,7 @@ export default eventHandler(async (ev) => { id: os.chapters[idx].id, posted: os.chapters[idx].posted, }); - replaceOrUploadContent(os.chapters![idx].id, cont); + await replaceOrUploadContent(os.chapters![idx].id, cont); } update.chapters![update.chapters!.length - 1].words = countWords(cont); }