Skip to content

Commit

Permalink
Improve stability of submitComment()
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Feb 12, 2024
1 parent f23cdcb commit dade916
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions apps/blog/app/[category]/[...slug]/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ export async function submitComment(_: State, formData: FormData): Promise<State
parentCommentId: formData.get("parentCommentId") as string,
};

await postComment(data);
revalidateTag(data.postSlug);
try {
await postComment(data);
revalidateTag(data.postSlug);

return {
message: "",
};
return {
message: "",
};
} catch (error) {
console.error(error);

return {
message: "댓글을 작성하는 중 오류가 발생했습니다.",
};
}
}

0 comments on commit dade916

Please sign in to comment.