Skip to content

Commit 2545e8f

Browse files
authored
Merge pull request #114 from danew/fix/optional-body
Allow reponse body to be optional
2 parents f22e699 + 4bdcfcd commit 2545e8f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: lib/serve.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ function createCallback(response) {
2424
for (const key in lambdaResponse.headers) {
2525
response.setHeader(key, lambdaResponse.headers[key]);
2626
}
27-
response.write(
28-
lambdaResponse.isBase64Encoded
29-
? Buffer.from(lambdaResponse.body, "base64")
30-
: lambdaResponse.body
31-
);
27+
28+
if (lambdaResponse.body) {
29+
response.write(
30+
lambdaResponse.isBase64Encoded
31+
? Buffer.from(lambdaResponse.body, "base64")
32+
: lambdaResponse.body
33+
);
34+
}
3235
response.end();
3336
}
3437
}

0 commit comments

Comments
 (0)