fix(api): update story editing route

properly await `replaceOrUpdateContent`
This commit is contained in:
parent 205b241e3b
commit 74722ddfd6
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -9,13 +9,7 @@ import { countWords } from "@functions";
import { messages } from "@server/constants";
export default eventHandler(async (ev) => {
let os:
| (Document<unknown, {}, IStory> &
IStory &
Required<{
_id: number;
}>)
| null = await storyQuerier(ev);
let os: (Document<unknown, {}, IStory> & 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);
}