Skip to content

Commit

Permalink
Merge pull request #29 from TheBronx/master
Browse files Browse the repository at this point in the history
dynamic queries with parameter
  • Loading branch information
matteofigus committed Mar 16, 2018
2 parents 3174d16 + 4b5a2b7 commit 38ff753
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/request-agent.js
Expand Up @@ -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);

Expand Down

0 comments on commit 38ff753

Please sign in to comment.