Skip to content

Commit 408e4a5

Browse files
committed
Navigate to new view only if request creation succeeded + better error display
1 parent 52e1d91 commit 408e4a5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ui/src/stores/main.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,16 @@ export const useMainStore = defineStore('main', {
176176
await axios.post<PostRequestResponse>(this.config.zimit_ui_api + '/requests', payload)
177177
).data
178178
this.taskId = response.id
179+
this.router.push({ name: 'request', params: { taskId: this.taskId } })
179180
} catch (error) {
180181
this.handleError(this.t('newRequest.errorCreatingRequest'), error)
181182
} finally {
182183
this.setLoading({ loading: false })
183184
}
184-
this.router.push({ name: 'request', params: { taskId: this.taskId } })
185185
},
186186
handleError(message: string, error: unknown) {
187-
if (error instanceof AxiosError) {
188-
console.error(message, ':', error.response?.status, error.response?.statusText)
187+
if (error instanceof AxiosError && error.response) {
188+
console.error(message, ':', error.response.status, error.response.statusText)
189189
} else {
190190
console.error(message, ':', error)
191191
}

0 commit comments

Comments
 (0)