From 0b46df7d64e122be4f42b71d666fa3bfa1404cff Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 20 Mar 2024 17:52:54 +0700 Subject: [PATCH] fix: when no family data response with null --- src/controllers/ProfileFamilyHistoryController.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileFamilyHistoryController.ts b/src/controllers/ProfileFamilyHistoryController.ts index 29456a4e..7a112091 100644 --- a/src/controllers/ProfileFamilyHistoryController.ts +++ b/src/controllers/ProfileFamilyHistoryController.ts @@ -101,10 +101,14 @@ export class ProfileFamilyHistoryController extends Controller { order: { createdAt: "DESC" }, where: { profileId }, }); - return new HttpSuccess({ - ...family[0], - children, - }); + return new HttpSuccess( + family.length > 0 + ? { + ...family[0], + children, + } + : null, + ); } @Get("history/{profileId}")