'Options' atribute as callback's aditional parameter #334

gvuyk opened this Issue Sep 30, 2012 · 1 comment

2 participants


Is there a way to get an attribute from the "Options" object to the callback function?
Something like this:

data = {'a': 'some data'}
request({url: 'http://example.com', userObj: data}, callback);

function callback(error,response,body,userObj)
       console.log(userObj);     // {  'a':  'some data' }

In my case, I'm making lots of requests and some of these requests needs to be made based on the parsed body of the previous one and an object created before the last request was made

Does it make sense?

request member

options get turned in to properties or function calls (depending on the option) during construction.

var r = request({url: 'http://example.com', userObj: data})
r.uri // url.parse() version of url
@mikeal mikeal closed this Oct 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment