React-native-fetch-blob: [Android] Cancel task

Created on 24 May 2017  路  5Comments  路  Source: wkh237/react-native-fetch-blob

Hi all, I am using fetch-blob in my react native application and I having some problems, only in android, cancelling the download.

I have

task = RNFetchBlob
.config({ path : path })
.fetch('GET', url, {})

task.then((res) => res)
.catch((err) => err )

When I run task.cancel() its works perfect on iOs devices returning the error, but when I do it in Android it returns the response of the 'then'.

Do you have any ideas? Thank you

RN: 0.43
Fetch-blob: ^0.10.4

Most helpful comment

i was ran into the same problem

All 5 comments

Just find out the same behavior

My current workaround:

if (this.task) {
    this.task.cancel();
    this.canceled = true;
}
///...
this.task.then((res) => {
if (res.respInfo.status == '200') {
///...
 if (this.canceled){ 
return;
}
}
}

@Crash-- Thank you, that solved my problem but the issue still there.

i was ran into the same problem

Would this relate to #268 ?

Closing this issue as there's already a possible fix in #268, related discussion will continue in that thread also.

Was this page helpful?
0 / 5 - 0 ratings