Created
December 3, 2014 17:32
-
-
Save hamishdickson/b2a9c71b90d5ef882c95 to your computer and use it in GitHub Desktop.
rest-call for MH
This file contains hidden or 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
exports.get_test_jobs = function(options, onResult) { | |
var optionsget = { | |
host: config.jobs_rest_host, | |
port: config.jobs_rest_port, | |
path: "/jobs3/jobtest", | |
method: "GET", | |
headers: { | |
'Content-Type': 'application/json' | |
} | |
}; | |
var reqGet = http.request(optionsget, function(res) { | |
var output = ''; | |
res.setEncoding('utf-8'); | |
res.on('data', function(chunk) { | |
output += chunk; | |
}); | |
res.on('end', function() { | |
var obj = JSON.parse(output); | |
onResult.send(res.statusCode, obj); | |
}); | |
}); | |
reqGet.end(); | |
reqGet.on('error', function(e) { | |
console.error('error: ' + e.message); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment