From b022e86e027d0a719387bd27bfeb9d6e239d42b5 Mon Sep 17 00:00:00 2001 From: Antony Kurniawan Date: Fri, 26 Sep 2025 11:04:04 +0700 Subject: [PATCH] fix: set response --- helpers/utils.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/helpers/utils.js b/helpers/utils.js index 41c60ed..716a5cc 100644 --- a/helpers/utils.js +++ b/helpers/utils.js @@ -1,12 +1,12 @@ -const setResponse = async (data = [], message = "success", statusCode = 200) => { - const response = { +const setResponse = (data = null, message = "success", statusCode = 200) => { + const total = Array.isArray(data) ? data.length : null; + + return { data, - total: data.length, + total, message, statusCode - } - - return response + }; }; const setResponsePaging = async (data = [], total, limit, page, message = "success", statusCode = 200) => {