| | |
| | | */ |
| | | async appointmentDemand(data: AppointmentParams) { |
| | | try { |
| | | const response = await http.post('/appointment/customer/create', data); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | // 弱掃Test4: 改為 promise.then 寫法 |
| | | return http.post('/appointment/customer/create', data).then((res) => { |
| | | if (res) { |
| | | return res['data']; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | }) |
| | | } catch (error) { |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | console.error('An error occurred while creating appointment demand:', error); |