Last active
May 1, 2021 08:37
-
-
Save johnpapa/1c2fd722e23c640de5eeb8ab3fa3e44a to your computer and use it in GitHub Desktop.
Our idea for simpler template code
This file contains hidden or 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
module.exports = async function (context, req) { | |
context.log('JavaScript HTTP trigger function processed a request.'); | |
const name = (req.query.name || (req.body && req.body.name)); | |
const responseMessage = name | |
? "Hello, " + name + ". This HTTP triggered function executed successfully." | |
: "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."; | |
context.res = { | |
// status: 200, /* Defaults to 200 */ | |
body: responseMessage | |
}; | |
} |
This file contains hidden or 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
module.exports = async function (context, req) { | |
context.log('HTTP trigger function processed a request.'); | |
const name = req.query.name || (req.body && req.body.name); | |
let message; | |
if (name) { | |
message = `Hello ${name}`; | |
} else { | |
message = `Pass a name in the query string or body to say hello.`; | |
} | |
context.res = { | |
body: message, | |
}; | |
}; |
We also updated the text to be more conversational.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For readability we are Intentionally avoiding optional chaining, ternary, and object value property shorthand