Skip to content

Instantly share code, notes, and snippets.

@65Mustang289
Created July 29, 2021 13:56
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 65Mustang289/a72c55484f9c5597d7fcb04636527581 to your computer and use it in GitHub Desktop.
Save 65Mustang289/a72c55484f9c5597d7fcb04636527581 to your computer and use it in GitHub Desktop.
// Description:
// Demo API
//
// Commands:
//
// Author:
// tad.hadtrath@optum.com
var url = require('url');
var querystring = require('querystring');
module.exports = function(robot) {
robot.router.get('/demo/api', function(req, res) {
var query = querystring.parse(url.parse(req.url).query);
var qsSearch = query['search'];
if(qsSearch && qsSearch.toLowerCase().trim() == "joe"){
res.send('[]');
return;
}
else if(qsSearch && qsSearch.toLowerCase().trim() == "jill"){
res.set('Content-Type', 'application/json');
res.send('[{"first": "Jill", "last": "Smith", "email": "jill@domain.org"}]');
return;
}
res.set('Content-Type', 'application/json');
res.send('[{"first": "Jill", "last": "Smith", "email": "jill@domain.org"},{"first": "Frank", "last": "Anderson", "email": "frank@domain.org"}]');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment