From a076b893ccaa34ea8ec16f459beeeb1a0beb4682 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Ansari Date: Tue, 22 Sep 2020 21:30:34 +0530 Subject: [PATCH] make response of web api with handler return data optional --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index da6829e..e21e1fc 100644 --- a/index.js +++ b/index.js @@ -106,10 +106,15 @@ module.exports = url => { app.methodToBeUsed( url, (req, res) => { - res.send(handler({ + const response = handler({ url: req.url, - query: req.query - })); + req: req, + res: res + }); + + if (response) { + res.send(response); + } } ); }