diff --git a/lib/request-agent.js b/lib/request-agent.js index 596410d..dc225e8 100644 --- a/lib/request-agent.js +++ b/lib/request-agent.js @@ -5,14 +5,14 @@ var _ = require('underscore'); module.exports = function(agent){ this.agent = agent; - var evalIfFunction = function(variable){ - return _.isFunction(variable) ? variable() : variable; + var evalIfFunction = function(variable, options){ + return _.isFunction(variable) ? variable(options) : variable; }; this.make = function(options, callback){ - var data = evalIfFunction(options.data) || {}, - query = evalIfFunction(options.query) || {}, - headers = evalIfFunction(options.headers) || {}, + var data = evalIfFunction(options.data, options) || {}, + query = evalIfFunction(options.query, options) || {}, + headers = evalIfFunction(options.headers, options) || {}, method = options.method === 'delete' ? 'del' : options.method, request = this.agent[method](options.url);