-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
每個有做 POST/PUT/DELETE 的元件都會有這段 pattern 出現,可以討論是否適合包成 hook
至少 catch 那邊的邏輯可以抽出來
new-front-end/src/pages/course/[name]/announcements/new.vue
Lines 33 to 53 in c77be18
| async function submit() { | |
| isLoading.value = true; | |
| try { | |
| const { annId } = ( | |
| await api.Announcement.create({ | |
| ...newAnnouncement, | |
| courseName: route.params.name as string, | |
| }) | |
| ).data; | |
| router.push(`/course/${route.params.name}/announcements/${annId}`); | |
| } catch (error) { | |
| if (axios.isAxiosError(error) && error.response?.data?.message) { | |
| errorMsg.value = error.response.data.message; | |
| } else { | |
| errorMsg.value = "Unknown error occurred :("; | |
| } | |
| throw error; | |
| } finally { | |
| isLoading.value = false; | |
| } | |
| } |
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Type
Projects
Status
🆕 New