quick-n-dirty-utils 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/functions.js +15 -3
  2. package/package.json +1 -1
package/dist/functions.js CHANGED
@@ -225,9 +225,21 @@ var qndUtils = {
225
225
  restHandler: function restHandler(response) {
226
226
  return new Promise(function (resolve, reject) {
227
227
  if (response.status >= 400) {
228
- reject({
229
- status: response.status,
230
- message: response.text()
228
+ response.text().then(function (responseContent) {
229
+ try {
230
+ // try to parse response into json
231
+ var responseJson = JSON.parse(responseContent);
232
+ reject({
233
+ status: response.status,
234
+ body: responseJson
235
+ });
236
+ } catch (err) {
237
+ // json parsing failed, just return as text
238
+ reject({
239
+ status: response.status,
240
+ body: responseContent
241
+ });
242
+ }
231
243
  });
232
244
  return;
233
245
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quick-n-dirty-utils",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Little useful nuggets for accelerated web development",
5
5
  "scripts": {
6
6
  "build": "./node_modules/.bin/babel src --out-dir ./dist",