From 3a08cbb1fba5983f5675f36ca4fdcf628f655bb0 Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 17 Aug 2018 23:15:51 +0800 Subject: [PATCH] fix response obj is null --- libs/route-utils/index.js | 2 +- route/api/index.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/route-utils/index.js b/libs/route-utils/index.js index ff5c26b..bcd03dd 100644 --- a/libs/route-utils/index.js +++ b/libs/route-utils/index.js @@ -81,7 +81,7 @@ const resObject = (key = null, message = null, msgCode = null) => { if (typeof message === 'string' && message.trim().length > 0) { resObj.obj.message = message.trim() - } else if (typeof message === 'object') { + } else if (message !== null && typeof message === 'object') { resObj.obj = message } return resObj diff --git a/route/api/index.js b/route/api/index.js index e716430..9c2a0fc 100644 --- a/route/api/index.js +++ b/route/api/index.js @@ -23,7 +23,6 @@ r.use(async (c, n) => { } catch (err) { console.log(err) obj = resObject(err instanceof APIError ? err.resKey : 'InternalError', err.apiMsg || null, err.msgCode || null) - console.log(obj) } if (Object.keys(c.obj).length > 0 && 'status' in c.obj && 'obj' in c.obj) {