-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
29 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
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 | ||
}; | ||
}; | ||
const { app } = require('@azure/functions'); | ||
|
||
app.http('httpTrigger1', { | ||
methods: ['GET', 'POST'], | ||
handler: async (req, context) => { | ||
context.log('JavaScript HTTP trigger function processed a request.'); | ||
|
||
let name; | ||
if (req.query.has('name')) { | ||
name = req.query.get('name') | ||
} else { | ||
let body = await req.json(); | ||
name = 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.'; | ||
|
||
return { body: responseMessage }; | ||
} | ||
}); |