Reputation: 59425
I am using the node request module which is setup as follows:
request(object,function(data));
The function is a callback with the response data in it. I want to feed in a predefined set of objects, and wrap the request function in another function like so:
var quickReq(object,func){
request(object,func);
}
quickReq({
"method":"GET",
"url":"http://someapi.com",
}
,function(error, response, data) {
res.send(data);
});
Is this valid async code?
Upvotes: 0
Views: 224
Reputation: 15003
It's not at all clear what you're trying to do, but the first parameter to request
's callback is an error code, and the second parameter is the returned content (assuming it succeeded).
Upvotes: 1