-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from SFDigitalServices/eval_body
EPR-466 take jsonata and data in POST body
- Loading branch information
Showing
4 changed files
with
129 additions
and
21 deletions.
There are no files selected for viewing
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
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,16 +1,19 @@ | ||
const jsonata = require("jsonata"); | ||
|
||
module.exports = async function (context, req) { | ||
|
||
context.log('JavaScript JSONata function processed a request.'); | ||
|
||
const has_data = (req.query.jsonata && req.body); | ||
const responseMessage = has_data | ||
? jsonata(req.query.jsonata).evaluate(req.body) | ||
: "This JSONata function executed successfully. Pass a jsonata in the query string and JSON in the request body for an evaluated response."; | ||
|
||
context.res = { | ||
// status: 200, /* Defaults to 200 */ | ||
body: responseMessage | ||
}; | ||
const jsonata = require("jsonata"); | ||
|
||
module.exports = async function (context, req) { | ||
|
||
context.log('JavaScript JSONata function processed a request.'); | ||
|
||
const has_data = (req.query.jsonata && req.body); | ||
const responseMessage = req.body ? has_data | ||
? jsonata(req.query.jsonata).evaluate(req.body) | ||
: (req.body.jsonata && req.body.data) | ||
? jsonata(req.body.jsonata).evaluate(req.body.data) | ||
: "This JSONata function executed successfully. Pass jsonata and data JSON for an evaluated response." | ||
: "This JSONata function executed successfully. Pass in paramenters for an evaluated response." | ||
|
||
context.res = { | ||
// status: 200, /* Defaults to 200 */ | ||
body: responseMessage | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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