Skip to content

Instantly share code, notes, and snippets.

@urouro-net
Created June 28, 2018 03:41
Show Gist options
  • Save urouro-net/2e802479a884cef5f084363874931404 to your computer and use it in GitHub Desktop.
Save urouro-net/2e802479a884cef5f084363874931404 to your computer and use it in GitHub Desktop.
Lambda + API Gateway Response Skelton
module.exports.handler = (event, context, callback) => {
const headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true
};
const invalidResponse = {
statusCode: 400,
headers,
body: JSON.stringify({ error: 'Invalid.' })
};
if (false) {
callback(null, invalidResponse);
return;
}
callback(null, {
statusCode: 200,
headers,
body: JSON.stringify({ message: 'Success' })
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment