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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ApiRequest.js +26 -6
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laravel-request",
3
3
  "productName": "laravel-request",
4
- "version": "1.1.13",
4
+ "version": "1.1.14",
5
5
  "description": "laravel-request",
6
6
  "main": "src/index.js",
7
7
  "scripts": {},
package/src/ApiRequest.js CHANGED
@@ -196,7 +196,13 @@ export default class ApiRequest {
196
196
 
197
197
  if(result)
198
198
  {
199
- notify = this.getNotifyManager().info('Успешно', response.meta.text)
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, status, errorText);
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, status, errorText)
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
- notify = this.getNotifyManager().error('Ошибка', errorText);
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
- notify = this.notify ? this.getNotifyManager().error('Ошибка') : null;
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) {