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) => {