From 4bdcfcd05b72bdb85f83f6066a120c4d5ab842ab Mon Sep 17 00:00:00 2001 From: Dane Wilson Date: Sun, 3 Feb 2019 02:04:28 -0500 Subject: [PATCH] Allow reponse body to be optional --- lib/serve.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/serve.js b/lib/serve.js index 4764a871..576a6ffd 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -24,11 +24,14 @@ function createCallback(response) { for (const key in lambdaResponse.headers) { response.setHeader(key, lambdaResponse.headers[key]); } - response.write( - lambdaResponse.isBase64Encoded - ? Buffer.from(lambdaResponse.body, "base64") - : lambdaResponse.body - ); + + if (lambdaResponse.body) { + response.write( + lambdaResponse.isBase64Encoded + ? Buffer.from(lambdaResponse.body, "base64") + : lambdaResponse.body + ); + } response.end(); } }