0

After looking at and experimenting with this code I have been unable to figure out what is going on and how I can use the information that is returned.

Where is "return callback(err, res, body)" returning to?

edit: I want to return the data stored in 'body' but its scope is only in that function thats in the call to 'request'. How do I get the data 'body' to return all the way out when i call 'makerequest' so i can use the 'body' data. I hope I am making sense

var makerequest = function(set_parameters, callback) {

         ....

 request(URL, function(err, res, body){
    return callback(err, res, body);
 });
};

1 Answers1

0

You access the JSON in the callback function:

makerequest(set_parameters, function(err, res, body){
      //do stuff with the body here
})
Tudor Constantin
  • 26,330
  • 7
  • 49
  • 72