Last active
December 25, 2022 06:41
-
-
Save therightstuff/342271102fd9fe363fa77125d9b48053 to your computer and use it in GitHub Desktop.
lambda handler for processing simple POST form data
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
exports.handler = async (event) => { | |
return new Promise(async (resolve) => { | |
const uriEncodedBody = event.body; | |
const uriEncodedBodyWithSpacesFixed = uriEncodedBody.replace(/\+/g, ' '); | |
const unencodedBody = decodeURIComponent(uriEncodedBodyWithSpacesFixed); | |
const arrayOfFormItems = unencodedBody.split('&'); | |
console.log(arrayOfFormItems); | |
resolve({ | |
"isBase64Encoded": false, | |
"statusCode": 501, | |
"headers": { | |
"Access-Control-Allow-Origin": "*", | |
"Access-Control-Allow-Credentials": true | |
}, // CORS headers | |
"body": "not implemented" | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment