laravel-request 1.1.40 → 1.1.42

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/Api.js +20 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laravel-request",
3
3
  "productName": "laravel-request",
4
- "version": "1.1.40",
4
+ "version": "1.1.42",
5
5
  "description": "laravel-request",
6
6
  "main": "src/index.js",
7
7
  "module": "src/index.js",
package/src/Api.js CHANGED
@@ -251,6 +251,15 @@ export default class Api {
251
251
  }
252
252
  }
253
253
 
254
+ static generateHash(length = 50) {
255
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
256
+ let hash = '';
257
+ for (let i = 0; i < length; i++) {
258
+ hash += chars.charAt(Math.floor(Math.random() * chars.length));
259
+ }
260
+ return hash;
261
+ }
262
+
254
263
  /**
255
264
  *
256
265
  * @param url
@@ -262,13 +271,16 @@ export default class Api {
262
271
  let query = Api.encodeQueryString(data);
263
272
  let response;
264
273
 
274
+ data.unique_hash = Api.generateHash();
275
+
265
276
  if (query.length > 5000) {
266
277
  data._method = 'GET';
267
278
  let request = {
268
279
  url: url,
269
280
  method: 'POST',
270
281
  data: data,
271
- headers: headers
282
+ headers: headers,
283
+ timeout: 0
272
284
  };
273
285
  Api.logRequest(request);
274
286
  response = await axios.request(request);
@@ -278,7 +290,8 @@ export default class Api {
278
290
  url: url,
279
291
  method: 'GET',
280
292
  params: data,
281
- headers: headers
293
+ headers: headers,
294
+ timeout: 0
282
295
  };
283
296
  Api.logRequest(request);
284
297
  response = await axios.request(request);
@@ -298,12 +311,16 @@ export default class Api {
298
311
  */
299
312
  static async handleDefaultRequest({ url, method, data, params, headers }) {
300
313
  params.timestamp = new Date().getTime();
314
+
315
+ params.unique_hash = Api.generateHash();
316
+
301
317
  let request = {
302
318
  url: url,
303
319
  method: method,
304
320
  data: data,
305
321
  params: params,
306
- headers: headers
322
+ headers: headers,
323
+ timeout: 0,
307
324
  };
308
325
  Api.logRequest(request);
309
326
  return await axios.request(request);