Skip to content

Instantly share code, notes, and snippets.

@craigshoemaker
Created November 2, 2018 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigshoemaker/8d7c8fbb10fadcd605fb8a35a7e81ff3 to your computer and use it in GitHub Desktop.
Save craigshoemaker/8d7c8fbb10fadcd605fb8a35a7e81ff3 to your computer and use it in GitHub Desktop.
Updated implementation for Functions Learn Module on Functions triggers and bindings
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