laravel-request 1.1.13 → 1.1.14
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/ApiRequest.js +26 -6
package/package.json
CHANGED
package/src/ApiRequest.js
CHANGED
|
@@ -196,7 +196,13 @@ export default class ApiRequest {
|
|
|
196
196
|
|
|
197
197
|
if(result)
|
|
198
198
|
{
|
|
199
|
-
|
|
199
|
+
if(response?.meta.text)
|
|
200
|
+
{
|
|
201
|
+
notify = this.getNotifyManager().info('Успешно', response.meta.text);
|
|
202
|
+
}else if(response?.meta.message)
|
|
203
|
+
{
|
|
204
|
+
notify = this.getNotifyManager().info('Успешно', response.meta.message);
|
|
205
|
+
}
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
self.toBind(response);
|
|
@@ -205,7 +211,7 @@ export default class ApiRequest {
|
|
|
205
211
|
}
|
|
206
212
|
},
|
|
207
213
|
error: (xhr, status, errorText) => {
|
|
208
|
-
this.handleError(notify, errorCallback, xhr,
|
|
214
|
+
this.handleError(notify, errorCallback, xhr, errorText);
|
|
209
215
|
}
|
|
210
216
|
});
|
|
211
217
|
|
|
@@ -217,11 +223,14 @@ export default class ApiRequest {
|
|
|
217
223
|
* @param notify
|
|
218
224
|
* @param errorCallback
|
|
219
225
|
* @param xhr
|
|
220
|
-
* @param status
|
|
221
226
|
* @param errorText
|
|
222
227
|
*/
|
|
223
|
-
handleError(notify, errorCallback, xhr,
|
|
228
|
+
handleError(notify, errorCallback, xhr, errorText)
|
|
224
229
|
{
|
|
230
|
+
console.log('------------')
|
|
231
|
+
console.log(xhr)
|
|
232
|
+
console.log(errorText)
|
|
233
|
+
|
|
225
234
|
if (xhr.readyState === 4) {
|
|
226
235
|
try {
|
|
227
236
|
let result = this.notifyCallback(xhr.status);
|
|
@@ -230,7 +239,13 @@ export default class ApiRequest {
|
|
|
230
239
|
{
|
|
231
240
|
switch (xhr.status) {
|
|
232
241
|
case 0://точно ошибка
|
|
233
|
-
|
|
242
|
+
if(errorText === 'Request aborted')
|
|
243
|
+
{
|
|
244
|
+
notify = this.getNotifyManager().errorOnce('request_aborted', 'Ошибка', errorText);
|
|
245
|
+
}else{
|
|
246
|
+
notify = this.getNotifyManager().error('Ошибка', errorText);
|
|
247
|
+
}
|
|
248
|
+
|
|
234
249
|
break;
|
|
235
250
|
case 404:
|
|
236
251
|
|
|
@@ -255,7 +270,12 @@ export default class ApiRequest {
|
|
|
255
270
|
}
|
|
256
271
|
} catch (e) {
|
|
257
272
|
console.error(e);
|
|
258
|
-
|
|
273
|
+
if(e?.message && typeof e.message === 'string')
|
|
274
|
+
{
|
|
275
|
+
notify = this.notify ? this.getNotifyManager().error('Ошибка', e.message) : null;
|
|
276
|
+
}else{
|
|
277
|
+
notify = this.notify ? this.getNotifyManager().error('Ошибка') : null;
|
|
278
|
+
}
|
|
259
279
|
}
|
|
260
280
|
}
|
|
261
281
|
else if (xhr.readyState === 0) {
|