quick-n-dirty-utils 1.0.2 → 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.
- package/dist/functions.js +16 -4
- package/package.json +1 -1
package/dist/functions.js
CHANGED
|
@@ -78,7 +78,7 @@ var qndUtils = {
|
|
|
78
78
|
|
|
79
79
|
// handling JS date objects
|
|
80
80
|
if (date instanceof Date) {
|
|
81
|
-
return this.formatDate(_luxon.DateTime.fromJSDate(date));
|
|
81
|
+
return this.formatDate(_luxon.DateTime.fromJSDate(date), dateFormat);
|
|
82
82
|
} // handling unix timestamps (guessing s or ms)
|
|
83
83
|
|
|
84
84
|
|
|
@@ -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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
}
|