From 3c17a06c6b1e099a618957bf7c1ddf93e0244a22 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期六, 05 八月 2023 18:00:53 +0800
Subject: [PATCH] Fixed: [弱掃] p17.2 Bad use of null-like value

---
 PAMapp/pages/questionnaire/_agentNo.vue |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/PAMapp/pages/questionnaire/_agentNo.vue b/PAMapp/pages/questionnaire/_agentNo.vue
index 69dcb60..e8e39a8 100644
--- a/PAMapp/pages/questionnaire/_agentNo.vue
+++ b/PAMapp/pages/questionnaire/_agentNo.vue
@@ -452,21 +452,30 @@
 
     ////////////////////////////////////////////////////////////////////////////
 
-    sentDemand() {
+    async sentDemand() {
       if (this.isEditBtn) {
-        this.editAppointmentDemand();
+        await this.editAppointmentDemand();
       } else {
-        queryConsultantService.addFavoriteConsultant([{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString()}]).then(res => this.sentAppointmentDemand());
-      }
-       const editSettingInfo: UserSetting = {
-          name: this.myRequest.name,
-          phone: this.myRequest.phone,
-          email: this.myRequest.email,
+        // 雿輻 async/await 靘��甇交����蝯��
+        const addFavoriteAgentList = [{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString() }];
+        const response = await queryConsultantService.addFavoriteConsultant(addFavoriteAgentList);
+
+        // 蝣箔�甇交����蝯�� null ��� undefined
+        if (response !== null) {
+          await this.sentAppointmentDemand();
+        } else {
+          throw new Error('queryConsultantService.addFavoriteConsultant returned null-like value.');
+        }
       }
 
-      accountSettingService.updateAccountSetting(editSettingInfo).then((_) => {
-          this.storageUserInfo(this.userInfo);
-      });
+      const editSettingInfo: UserSetting = {
+        name: this.myRequest.name,
+        phone: this.myRequest.phone,
+        email: this.myRequest.email,
+      };
+
+      await accountSettingService.updateAccountSetting(editSettingInfo);
+      this.storageUserInfo(this.userInfo);
     }
 
     private editAppointmentDemand() {

--
Gitblit v1.8.0