I'm having the request script as below and saved as pageRequest.js.
pageRequest.js:
var request = require('request');
var options = {
method: 'get',
url: 'http://xx.xx.xx.x/api/....'
};
function callback(error, response, body) {
var info1 = JSON.parse(body);
global.info = info1;
}
request(options, callback);
Now I'm executing the above script as part of my protractor onPrepare function. But I need to convert the above pageRequest.js as function and need to call inside my script. can any one help me on this.