File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,12 @@ class ReactNativeBlobUtilFetchPolyfill {
59
59
// task.then is not, so we have to extend task.then with progress and
60
60
// cancel function
61
61
let progressHandler , uploadHandler , cancelHandler ;
62
+ let scopedTask = null ;
62
63
let statefulPromise = promise
63
64
. then ( ( body ) => {
64
65
let task = RNconfig ( config )
65
66
. fetch ( options . method , url , options . headers , body ) ;
67
+ scopedTask = task ;
66
68
if ( progressHandler )
67
69
task . progress ( progressHandler ) ;
68
70
if ( uploadHandler )
@@ -87,8 +89,8 @@ class ReactNativeBlobUtilFetchPolyfill {
87
89
} ;
88
90
statefulPromise . cancel = ( ) => {
89
91
cancelHandler = true ;
90
- if ( task . cancel )
91
- task . cancel ( ) ;
92
+ if ( scopedTask && scopedTask . cancel )
93
+ scopedTask . cancel ( ) ;
92
94
} ;
93
95
94
96
return statefulPromise ;
You can’t perform that action at this time.
0 commit comments