Skip to content

Instantly share code, notes, and snippets.

@therightstuff
Last active December 25, 2022 06:41
Show Gist options
  • Save therightstuff/342271102fd9fe363fa77125d9b48053 to your computer and use it in GitHub Desktop.
Save therightstuff/342271102fd9fe363fa77125d9b48053 to your computer and use it in GitHub Desktop.
lambda handler for processing simple POST form data
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