0

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?

1
  • It's valid, but why do you need to wrap a request into a 'twin' object - i.e., without any additional functionality in this wrapper?
    – raina77ow
    Jul 29, 2012 at 10:49

2 Answers 2

2

Is this valid async code?

Yes, yes it is.

1

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.