Created
May 8, 2018 14:17
-
-
Save adnanrahic/e8b45fb452f5ce53d3907b9f184b22c8 to your computer and use it in GitHub Desktop.
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
// Node.js v.8.10 | |
module.exports.login = (event, context) => { | |
return connectToDatabase() // returning promise! :) | |
.then(() => | |
login(JSON.parse(event.body)) // promise | |
) | |
.then(session => ({ // resolving the promise to an object | |
statusCode: 200, | |
body: JSON.stringify(session) | |
})) | |
.catch(err => ({ // or rejecting with an error | |
statusCode: 500, | |
body: JSON.stringify(err) | |
})); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment