resource-client
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -10,2 +10,7 @@ // Generated by CoffeeScript 1.8.0 | ||
}, | ||
'queryOne': { | ||
method: 'GET', | ||
isArray: true, | ||
returnFirst: true | ||
}, | ||
'save': { | ||
@@ -12,0 +17,0 @@ method: 'POST' |
@@ -62,3 +62,3 @@ // Generated by CoffeeScript 1.8.0 | ||
}, function(err, response) { | ||
return handleResponse(err, response, null, done); | ||
return handleResponse(err, response, null, done, options); | ||
}); | ||
@@ -116,4 +116,7 @@ }; | ||
}; | ||
handleResponse = function(err, response, originalObject, done) { | ||
var resource, resources, _ref; | ||
handleResponse = function(err, response, originalObject, done, options) { | ||
var errorMessage, resource, resources, _ref; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if (err) { | ||
@@ -126,2 +129,5 @@ return done(err); | ||
}); | ||
if (options.returnFirst) { | ||
resources = resources[0]; | ||
} | ||
return done(null, resources); | ||
@@ -135,3 +141,4 @@ } else { | ||
} else { | ||
return done(response.body); | ||
errorMessage = JSON.stringify(response.body); | ||
return done(new Error(errorMessage)); | ||
} | ||
@@ -138,0 +145,0 @@ }; |
{ | ||
"name": "resource-client", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Easily create api clients for your server side resources.", | ||
@@ -27,3 +27,4 @@ "author": "Good Eggs <open-source@goodeggs.com>", | ||
"lodash": "^3.0.0", | ||
"url-assembler": "0.0.3" | ||
"url-assembler": "0.0.3", | ||
"chai": "^2.1.0" | ||
}, | ||
@@ -30,0 +31,0 @@ "devDependencies": { |
@@ -60,2 +60,3 @@ # Resource Client | ||
- **isArray** - resource is an array. It will not populate variables in the url. | ||
- **returnFirst** - resource is an array. It will return the first result from the array | ||
@@ -76,2 +77,8 @@ ```javascript | ||
}); | ||
Product.action('queryOne', { | ||
method: 'GET' | ||
isArray: true | ||
returnFirst: true | ||
}); | ||
``` | ||
@@ -106,2 +113,3 @@ | ||
- **query** - {method: 'GET', isArray: true} | ||
- **queryOne** - {method: 'GET', isArray: true, returnFirst: true} | ||
- **update** - {method: 'PUT'} | ||
@@ -108,0 +116,0 @@ - **save** - {method: 'POST'} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
18793
169
128
4
+ Addedchai@^2.1.0
+ Addedassertion-error@1.0.0(transitive)
+ Addedchai@2.3.0(transitive)
+ Addeddeep-eql@0.1.3(transitive)
+ Addedpsl@1.14.0(transitive)
+ Addedtype-detect@0.1.1(transitive)
- Removedpsl@1.13.0(transitive)