laravel-request 1.2.2 → 1.2.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/package.json +1 -1
- package/src/Api.js +27 -14
package/package.json
CHANGED
package/src/Api.js
CHANGED
|
@@ -37,9 +37,9 @@ export default class Api {
|
|
|
37
37
|
*
|
|
38
38
|
* @return {string}
|
|
39
39
|
*/
|
|
40
|
-
static
|
|
40
|
+
static isDebug = () =>
|
|
41
41
|
{
|
|
42
|
-
return process.env.
|
|
42
|
+
return process.env.REACT_APP_DEBUG === 'true';
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -211,7 +211,7 @@ export default class Api {
|
|
|
211
211
|
|
|
212
212
|
const data = decode(arrayBuffer);
|
|
213
213
|
|
|
214
|
-
if(this.
|
|
214
|
+
if(this.isDebug())
|
|
215
215
|
{
|
|
216
216
|
console.log(url)
|
|
217
217
|
console.log(data)
|
|
@@ -297,18 +297,31 @@ export default class Api {
|
|
|
297
297
|
console.error(e);
|
|
298
298
|
|
|
299
299
|
const response = e.response;
|
|
300
|
-
const xhr = response.request;
|
|
301
300
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
301
|
+
//если прервали запрос или проблему с соединение то response может не быть
|
|
302
|
+
if(response)
|
|
303
|
+
{
|
|
304
|
+
const xhr = response.request;
|
|
305
|
+
|
|
306
|
+
const contentType = response.headers.get("Content-Type");
|
|
307
|
+
const responseData = await Api.decodeResponse(url, response, contentType);
|
|
308
|
+
|
|
309
|
+
const statusCode = response.status;
|
|
310
|
+
const statusText = response.statusText;
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
error(xhr, responseData, statusCode, statusText);
|
|
314
|
+
}catch (error){
|
|
315
|
+
console.error(error);
|
|
316
|
+
}
|
|
317
|
+
}else{
|
|
318
|
+
console.error(e)
|
|
319
|
+
|
|
320
|
+
try {
|
|
321
|
+
error({}, {}, '', e.message);
|
|
322
|
+
}catch (error){
|
|
323
|
+
console.error(error);
|
|
324
|
+
}
|
|
312
325
|
}
|
|
313
326
|
}else{
|
|
314
327
|
console.error(e)
|