joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

Error code is always 16 on catch #715

Open Dukler opened 3 years ago

Dukler commented 3 years ago

I'm making a request to download a file, when downloading works as intended, meaning it downloads the file no problems here. But when the download fails, due to any server error (404, 400, etc.), and I catch the error, the status code is always the same, 16, and I don't seem to be able to get the actual status code from the response, making me unable to properly handle any http errors coming my way. I'm using "rn-fetch-blob": "^0.12.0".

Here's a snippet of my code, is there something wrong, or is it a bug?

const {dirs} = RNFetchBlob.fs;
        RNFetchBlob.config({
            fileCache: true,
            addAndroidDownloads: {
                useDownloadManager: true,
                notification: true,
                mediaScannable: true,
                title: `${data.title}.pdf`,
                path: `${dirs.DownloadDir}/${data.title}`,
            },
        })
            .fetch('GET', "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy1.pdf", {
                nonStandard: "true",
                session: await getToken()
            })
            . then((res) => {
                console.log('The file saved to ', res.path());
            })
            .catch(e => {
                console.log(e);
            });
SmirnovM91 commented 3 years ago

+1

Dukler commented 3 years ago

So, any solutions to this?

joseocabarcas commented 3 years ago

Any solutions ?

GustavoWestarb commented 3 years ago

Same problem here.

ajoykarmakar commented 3 years ago

Encountered in android 11 only.

AndiCrisan commented 2 years ago

Has anyone found a solution for this?