I'm trying to create a callback function, but keep getting told that data is not a function. I've set it up according to another question, but does not seem to work?
getRequest("http://", function(error, data){
console.log(data);
});
function getRequest(url, error, data) {
request({
method: 'GET',
uri: url,
headers: {
'Content-Type': 'application/json',
'dataType': 'json'}
}, function (error, response, body){
if(!error && response.statusCode == 200){
data(JSON.parse(body));
} else {
error(error);
}
})
}
getRequestwith two params. so the thirddataparam isundefined.then(...)is often a lot easier than matching up function calls.