rest-facade
Advanced tools
Comparing version 1.2.1 to 1.2.2
{ | ||
"name": "rest-facade", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Simple abstraction for consuming REST API endpoints", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -166,1 +166,8 @@ # rest-facade [![Build Status](https://travis-ci.org/ngonzalvez/rest-facade.svg?branch=master)](https://travis-ci.org/ngonzalvez/rest-facade) | ||
~~~ | ||
#### Arrays | ||
By default, arrays in the querystring will be formmated this way: `?a=1&a=2&a=2`. However, you can change it to comma separated values `?a=1,2,3` by setting the `query.repeatParams` option to `false`. | ||
~~~js | ||
var client = new rest.Client(url, { query: { repeatParams: false }}); | ||
~~~ |
@@ -8,2 +8,3 @@ var extend = require('util')._extend; | ||
var ArgumentError = require('./exceptions').ArgumentError; | ||
var defaultOptions = require('./defaultOptions'); | ||
@@ -23,4 +24,3 @@ | ||
this.options = options || {}; | ||
this.options.query = this.options.query || { convertCase: null }; | ||
this.options = extend(defaultOptions, options); | ||
this.url = url.parse(resourceUrl); | ||
@@ -52,3 +52,3 @@ }; | ||
} else if (typeof arguments[0] === 'object') { | ||
parmas = arguments[0]; | ||
params = arguments[0]; | ||
} | ||
@@ -233,2 +233,3 @@ | ||
var newKey = null; | ||
var value = null; | ||
@@ -242,3 +243,12 @@ // If the user specified a convertion case (e.g. 'snakeCase') convert all the | ||
newKey = convertCase(prevKey); | ||
queryParams[newKey] = params[prevKey]; | ||
value = params[prevKey]; | ||
// If the repeatParams flag is set to false, encode arrays in | ||
// the querystring as comma separated values. | ||
// e.g. ?a=1,2,3 | ||
if (Array.isArray(value) && !this.options.query.repeatParams) { | ||
value = value.join(','); | ||
} | ||
queryParams[newKey] = value; | ||
} | ||
@@ -245,0 +255,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33158
16
728
173