esoftplay 0.0.111-y → 0.0.112
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/modules/lib/curl.ts +71 -58
- package/package.json +1 -1
package/modules/lib/curl.ts
CHANGED
|
@@ -167,33 +167,30 @@ export default class ecurl {
|
|
|
167
167
|
}
|
|
168
168
|
let ps = Object.keys(_post).map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(_post[key])).join('&');
|
|
169
169
|
var options: any = {
|
|
170
|
-
|
|
170
|
+
signal: this.signal,
|
|
171
171
|
method: "POST",
|
|
172
|
-
cancelToken: this.abort.token,
|
|
173
|
-
transformResponse: [(data) => { return data; }],
|
|
174
172
|
headers: {
|
|
175
173
|
...this.header,
|
|
176
174
|
["Content-Type"]: "application/x-www-form-urlencoded;charset=UTF-8"
|
|
177
175
|
},
|
|
178
|
-
|
|
176
|
+
body: ps,
|
|
179
177
|
cache: "no-store",
|
|
180
178
|
_post: _post
|
|
181
179
|
}
|
|
182
|
-
this.
|
|
183
|
-
|
|
184
|
-
this.cancelTimeout();
|
|
185
|
-
let resText = res.data;
|
|
180
|
+
fetch(this.url + this.uri + (token_uri || 'get_token'), options).then(async (res) => {
|
|
181
|
+
let resText = await res.text()
|
|
186
182
|
this.onFetched(resText,
|
|
187
183
|
(res, msg) => {
|
|
188
184
|
this.init(uri, { ...post, access_token: res }, onDone, onFailed, debug);
|
|
189
185
|
}, (msg) => {
|
|
190
186
|
if (onFailed)
|
|
191
|
-
onFailed(
|
|
187
|
+
onFailed(msg, false)
|
|
192
188
|
}, debug)
|
|
193
|
-
}).catch((r
|
|
194
|
-
this.cancelTimeout();
|
|
195
|
-
LibToastProperty.show("Koneksi internet anda tidak stabil, silahkan coba beberapa saat lagi")
|
|
189
|
+
}).catch((r) => {
|
|
196
190
|
LibProgress.hide()
|
|
191
|
+
this.onFetchFailed(r)
|
|
192
|
+
// if (onFailed)
|
|
193
|
+
// onFailed(r, true)
|
|
197
194
|
})
|
|
198
195
|
}
|
|
199
196
|
}
|
|
@@ -289,7 +286,6 @@ export default class ecurl {
|
|
|
289
286
|
}
|
|
290
287
|
await this.setHeader()
|
|
291
288
|
var options: any = {
|
|
292
|
-
url: this.url + this.uri,
|
|
293
289
|
signal: this.signal,
|
|
294
290
|
method: !this.post ? "GET" : "POST",
|
|
295
291
|
headers: {
|
|
@@ -313,14 +309,39 @@ export default class ecurl {
|
|
|
313
309
|
if (onDone) onDone(resJson, false)
|
|
314
310
|
this.onDone(resJson)
|
|
315
311
|
} else {
|
|
312
|
+
// Alert.alert(this.alertTimeout.title, this.alertTimeout.message, [
|
|
313
|
+
// {
|
|
314
|
+
// text: this.alertTimeout.ok,
|
|
315
|
+
// style: 'cancel',
|
|
316
|
+
// onPress: () => this.custom(uri, post, onDone, debug)
|
|
317
|
+
// },
|
|
318
|
+
// {
|
|
319
|
+
// text: this.alertTimeout.cancel,
|
|
320
|
+
// style: 'destructive',
|
|
321
|
+
// onPress: () => { }
|
|
322
|
+
// }
|
|
323
|
+
// ])
|
|
316
324
|
this.onFetchFailed(resText)
|
|
317
325
|
LibProgress.hide()
|
|
318
326
|
this.onError(resText)
|
|
319
327
|
}
|
|
320
328
|
}).catch((e) => {
|
|
321
|
-
this.onError(e)
|
|
322
329
|
LibProgress.hide()
|
|
330
|
+
// Alert.alert(this.alertTimeout.title, this.alertTimeout.message, [
|
|
331
|
+
// {
|
|
332
|
+
// text: this.alertTimeout.ok,
|
|
333
|
+
// style: 'cancel',
|
|
334
|
+
// onPress: () => this.custom(uri, post, onDone, debug)
|
|
335
|
+
// },
|
|
336
|
+
// {
|
|
337
|
+
// text: this.alertTimeout.cancel,
|
|
338
|
+
// style: 'destructive',
|
|
339
|
+
// onPress: () => { }
|
|
340
|
+
// }
|
|
341
|
+
// ])
|
|
323
342
|
this.onFetchFailed(e)
|
|
343
|
+
// if (onDone)
|
|
344
|
+
// onDone(e, true)
|
|
324
345
|
})
|
|
325
346
|
}
|
|
326
347
|
}
|
|
@@ -354,23 +375,18 @@ export default class ecurl {
|
|
|
354
375
|
if (!upload)
|
|
355
376
|
this.header["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8"
|
|
356
377
|
var options: any = {
|
|
357
|
-
|
|
378
|
+
signal: this.signal,
|
|
358
379
|
method: !this.post ? "GET" : "POST",
|
|
359
380
|
headers: this.header,
|
|
360
|
-
|
|
361
|
-
data: !this.post ? undefined : this.post,
|
|
362
|
-
cancelToken: this.abort.token,
|
|
381
|
+
body: this.post,
|
|
363
382
|
cache: "no-store",
|
|
364
|
-
|
|
365
383
|
Pragma: "no-cache",
|
|
366
384
|
["Cache-Control"]: 'no-cache, no-store, must-revalidate',
|
|
367
385
|
["Expires"]: 0,
|
|
368
386
|
mode: "cors",
|
|
369
387
|
_post: post
|
|
370
388
|
}
|
|
371
|
-
|
|
372
|
-
esp.log(this.url + this.uri, { ...options, cancelToken: undefined })
|
|
373
|
-
}
|
|
389
|
+
|
|
374
390
|
|
|
375
391
|
if (manifest?.packagerOpts?.dev && LogStateProperty) {
|
|
376
392
|
const allData = LogStateProperty.state().get() || []
|
|
@@ -429,45 +445,42 @@ export default class ecurl {
|
|
|
429
445
|
}
|
|
430
446
|
}
|
|
431
447
|
|
|
432
|
-
this.fetchConf = { url: this.url + this.uri, options: options }
|
|
433
448
|
this.initTimeout(upload ? 120000 : undefined)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
this.onError(JSON.stringify(error.message))
|
|
467
|
-
console.log('Error', error.message);
|
|
468
|
-
}
|
|
449
|
+
if (debug == 1) esp.log(this.url + this.uri, options)
|
|
450
|
+
this.fetchConf = { url: this.url + this.uri, options: options }
|
|
451
|
+
|
|
452
|
+
// if (Platform.OS == 'android' && Platform.Version <= 22) {
|
|
453
|
+
// var res = await fetch(this.url + this.uri, options);
|
|
454
|
+
// let resText = await res.text()
|
|
455
|
+
// this.onFetched(resText, onDone, onFailed, debug)
|
|
456
|
+
// } else
|
|
457
|
+
// if (!upload) {
|
|
458
|
+
// LibWorker.curl(this.url + this.uri, options, async (resText) => {
|
|
459
|
+
// if (typeof resText == 'string') {
|
|
460
|
+
// this.onFetched(resText, onDone, onFailed, debug)
|
|
461
|
+
// }
|
|
462
|
+
// })
|
|
463
|
+
// } else {
|
|
464
|
+
fetch(this.url + this.uri, options).then(async (res) => {
|
|
465
|
+
let resText = await res.text()
|
|
466
|
+
this.onFetched(resText, onDone, onFailed, debug)
|
|
467
|
+
}).catch((r) => {
|
|
468
|
+
// Alert.alert(this.alertTimeout.title, this.alertTimeout.message, [
|
|
469
|
+
// {
|
|
470
|
+
// text: this.alertTimeout.ok,
|
|
471
|
+
// style: 'cancel',
|
|
472
|
+
// onPress: () => this.init(uri, post, onDone, onFailed, debug)
|
|
473
|
+
// },
|
|
474
|
+
// {
|
|
475
|
+
// text: this.alertTimeout.cancel,
|
|
476
|
+
// style: 'destructive',
|
|
477
|
+
// onPress: () => { }
|
|
478
|
+
// }
|
|
479
|
+
// ])
|
|
480
|
+
this.onFetchFailed(r)
|
|
469
481
|
LibProgress.hide()
|
|
470
482
|
})
|
|
483
|
+
// }
|
|
471
484
|
}
|
|
472
485
|
|
|
473
486
|
|