Skip to content

Instantly share code, notes, and snippets.

@adnanrahic
Created May 8, 2018 14:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
// 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