Created
April 17, 2018 11:37
-
-
Save emmiep/9cc30673f4a16c8ae7e222741490f817 to your computer and use it in GitHub Desktop.
Setting a status code with stdlib
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
const users = [ | |
'stdlib' | |
]; | |
/** | |
* A basic Hello World function | |
* @param {string} name Who you're saying hello to | |
* @returns {object.http} | |
*/ | |
module.exports = async (name, context) => { | |
if (users.includes(name)) { | |
return { | |
statusCode: 200, | |
body: `Hello ${name}!` | |
}; | |
} else { | |
return { | |
statusCode: 404, | |
body: 'No such user' | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment