Created
November 4, 2018 06:58
-
-
Save rlingineni/1021c916e49d36ab415b648bcac5bfcc to your computer and use it in GitHub Desktop.
AWS Lambda Proxy Response Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Helper function for AWS Lambda API responses, can pass in JSON or string and status code and message to respond with | |
function BuildResponse(statusCode, responseBody, shouldStringify = false) { | |
let body = "invalid response"; | |
if (shouldStringify) { | |
body = JSON.stringify(responseBody); | |
} else { | |
body = JSON.stringify({ msg: responseBody }); | |
} | |
let response = { | |
statusCode, | |
body | |
}; | |
return response; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment