-
-
Save 65Mustang289/a72c55484f9c5597d7fcb04636527581 to your computer and use it in GitHub Desktop.
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
// 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