Created
November 2, 2018 19:48
-
-
Save craigshoemaker/8d7c8fbb10fadcd605fb8a35a7e81ff3 to your computer and use it in GitHub Desktop.
Updated implementation for Functions Learn Module on Functions triggers and bindings
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
module.exports = function (context, req) { | |
var response = { | |
status: 200, | |
headers: { "Content-Type": "application-json" } | |
}; | |
if (req.query.id || req.body && req.body.id) { | |
var bookmark = context.bindings.bookmark; | |
if(bookmark) { | |
response.body = { "URL": bookmark.URL }; | |
} | |
else { | |
response.status = 404; | |
response.body = "No bookmarks found"; | |
} | |
} | |
else { | |
response.status = 400; | |
response.body = "Please pass a value for id on the query string or in the request body"; | |
} | |
context.res = response; | |
context.done(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment