From f1a5cfffd44cf0bb8f48bd7cb02ee3d474a65de8 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: Sat, 16 Mar 2024 15:43:26 -0400 Subject: [PATCH] fix(api): fall back to grabbing the current element's _id in `replaceOrUploadContent` call --- server/api/story/[id]/index.put.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/api/story/[id]/index.put.ts b/server/api/story/[id]/index.put.ts index 5ccd22e..68e7a63 100644 --- a/server/api/story/[id]/index.put.ts +++ b/server/api/story/[id]/index.put.ts @@ -47,7 +47,8 @@ export default eventHandler(async (ev) => { posted: os.chapters[idx].posted, }); } - await replaceOrUploadContent(os.chapters![idx].id, cont); + + await replaceOrUploadContent(os.chapters![idx]?.id ?? c._id, cont); update.chapters![update.chapters!.length - 1].words = countWords(cont); } os = await Story.findOneAndUpdate(