Skip to content

Commit

Permalink
convert external function to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
derkoe committed Jul 15, 2024
1 parent 126fe0c commit 7b61b16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
16 changes: 0 additions & 16 deletions demo/func/HelloWorld/function.json

This file was deleted.

35 changes: 22 additions & 13 deletions demo/func/HelloWorld/index.js
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 };
}
});

0 comments on commit 7b61b16

Please sign in to comment.