From 965db8f11b4ce3df0c0604cc5f008d42aa6db7d4 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期六, 05 八月 2023 18:06:43 +0800 Subject: [PATCH] Fixed: [弱掃] p19.1 Bad use of null-like value --- PAMapp/shared/services/query-consultant.service.ts | 36 ++++++++++++++++++++++++++++++++---- 1 files changed, 32 insertions(+), 4 deletions(-) diff --git a/PAMapp/shared/services/query-consultant.service.ts b/PAMapp/shared/services/query-consultant.service.ts index fdc5507..8da40cd 100644 --- a/PAMapp/shared/services/query-consultant.service.ts +++ b/PAMapp/shared/services/query-consultant.service.ts @@ -14,8 +14,20 @@ // 敹恍�祟� async fastQuery(data: FastQueryParams): Promise<Consultant[]> { - return http.post<Consultant[]>('/consultant/fastQuery', data).then(res => res.data); + try { + const response = await http.post<Consultant[]>('/consultant/fastQuery', data); + if (response !== null) { + return response.data; + } else { + throw new Error('http.post returned null-like value.'); + } + } catch (error) { + console.error('An error occurred while performing fast query:', error); + // �隞亙甇方���隤斗����身�� + throw error; + } } + // ������ async strictQuery(data:StrictQueryParams): Promise<AgentOfStrictQuery[]>{ @@ -30,11 +42,27 @@ return http.post('/consultant/favorite', payload); } - // ����岷��� - async appointmentDemand(data: AppointmentParams) { - return http.post('/appointment/customer/create', data).then((res) => res.data); + /** + * ����瘙� + * @param data ������瘙�����隞� + * @returns ������瘙��� + */ + 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.'); + } + } catch (error) { + // �隞亙甇方���隤斗����身�� + console.error('An error occurred while creating appointment demand:', error); + throw error; + } } + } export default new QueryConsultantService(); -- Gitblit v1.8.0