-
-
Save 65Mustang289/4d422b27eaa866558f74e7f4a8ec26ee 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
Add the following in scripts/sampleFunctions.js | |
// Description: | |
// Sample Functions | |
// | |
// Author: | |
// tad.hadtrath@optum.com | |
module.exports = function(robot) { | |
module.exports = { | |
searchApi: async function(search){ | |
var url = "http://localhost:8080/demo/api?search=" + search; | |
return new Promise((resolve, reject) => | |
robot.http(url) | |
.headers({'Accept': 'application/json'}) | |
.get()((err, res, body) => { | |
if (err != null) { | |
reject(err); | |
return; | |
} | |
switch (res.statusCode) { | |
case 200: | |
resolve(JSON.parse(body)); | |
break; | |
default: | |
reject(res.statusCode + " status code returned"); | |
} | |
}) | |
); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment