Skip to content

Instantly share code, notes, and snippets.

@jatazoulja
Created August 28, 2017 02:00
Show Gist options
  • Save jatazoulja/f688ff7871f3ed304e2e25cfbe9a6c52 to your computer and use it in GitHub Desktop.
Save jatazoulja/f688ff7871f3ed304e2e25cfbe9a6c52 to your computer and use it in GitHub Desktop.
response.lib.js
export function success(body) {
return buildResponse(200, body);
}
export function failure(body) {
return buildResponse(500, body);
}
function buildResponse(statusCode, body) {
return {
statusCode: statusCode,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true,
},
body: JSON.stringify(body),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment