Skip to content

Commit 2d3700d

Browse files
committed
better handle in case of null and undefined result
1 parent c8f4cc8 commit 2d3700d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ function translateLambdaResultIfNeeded(result, isV1) {
251251
return result;
252252
}
253253

254-
if (!result.statusCode && (typeof result === 'object' || typeof result === 'string')) {
254+
if ((!result || !result.statusCode) && (typeof result === 'object' || typeof result === 'string' || typeof result === 'undefined')) {
255255
return {
256-
"isBase64Encoded": false,
257-
"statusCode": 200,
258-
"body": JSON.stringify(result),
259-
"headers": {
260-
"content-type": "application/json"
256+
isBase64Encoded: false,
257+
statusCode: 200,
258+
body: typeof result === 'undefined' ? undefined : JSON.stringify(result),
259+
headers: {
260+
'content-type': 'application/json'
261261
}
262-
}
262+
};
263263
}
264264

265265
return result || {};

0 commit comments

Comments
 (0)