Browse Source

Cancel download throw error bugfix (Android)

Emmett Harper 5 years ago
parent
commit
da40583878
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      index.js

+ 7
- 0
index.js View File

229
     return fetchFile(options, method, url, headers, body)
229
     return fetchFile(options, method, url, headers, body)
230
   }
230
   }
231
 
231
 
232
+  let promiseResolve;
233
+  let promiseReject;
234
+
232
   // from remote HTTP(S)
235
   // from remote HTTP(S)
233
   let promise = new Promise((resolve, reject) => {
236
   let promise = new Promise((resolve, reject) => {
237
+    promiseResolve = resolve;
238
+    promiseReject = reject;
239
+
234
     let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'
240
     let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'
235
 
241
 
236
     // on progress event listener
242
     // on progress event listener
371
     subscriptionUpload.remove()
377
     subscriptionUpload.remove()
372
     stateEvent.remove()
378
     stateEvent.remove()
373
     RNFetchBlob.cancelRequest(taskId, fn)
379
     RNFetchBlob.cancelRequest(taskId, fn)
380
+    promiseReject(new Error("canceled"))
374
   }
381
   }
375
   promise.taskId = taskId
382
   promise.taskId = taskId
376
 
383