We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 481d45e commit 99b7dbcCopy full SHA for 99b7dbc
1 file changed
src/entities/slogan/lib/handleSloganFormSubmit.ts
@@ -5,13 +5,12 @@ import { postSlogan } from "../api/postSlogan";
5
export async function handleSloganFormSubmit(values: SloganFormValues): Promise<boolean> {
6
try {
7
const res = await postSlogan(values);
8
- if (res.status === 200 || res.status === 201) {
9
- toast.success("슬로건이 제출되었습니다.");
10
- return true;
+ if (res.status !== 200 && res.status !== 201) {
+ throw new Error(`API request failed with status ${res.status}`);
11
}
12
- toast.error("슬로건 제출에 실패했습니다.");
13
- return false;
14
- } catch {
+ toast.success("슬로건이 제출되었습니다.");
+ return true;
+ } catch (error) {
15
toast.error("슬로건 제출에 실패했습니다.");
16
return false;
17
0 commit comments