| | |
| | | * @returns 回傳結案結果 |
| | | */ |
| | | async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) { |
| | | // 弱掃Test5: 重新包裝為 promise |
| | | try { |
| | | const response = await http.post(`/appointment/close`, appointmentInfo); |
| | | const responsePromise = new Promise((resolve, reject) => { |
| | | if (response !== null) { |
| | | resolve(response.data); |
| | | } else { |
| | | reject('http.post returned null-like value.'); |
| | | } |
| | | }); |
| | | if (!response) { |
| | | throw new Error('http.post returned null-like value.'); |
| | | throw new Error('http.post returned a null-like value.'); |
| | | } else { |
| | | return responsePromise.then(res => res); |
| | | return response.data; |
| | | } |
| | | } catch (error) { |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | // 在這裡處理錯誤,例如回傳預設值或記錄錯誤訊息 |
| | | console.error('An error occurred while closing appointment:', error); |
| | | throw error; |
| | | } |