Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

TypeError when trying to download file #488

Open
centotaure opened this issue Aug 16, 2017 · 2 comments
Open

TypeError when trying to download file #488

centotaure opened this issue Aug 16, 2017 · 2 comments

Comments

@centotaure
Copy link

centotaure commented Aug 16, 2017

Hey everyone, I'm trying to get my app to download a file and open it with the default phone application, the simple fetch to get my file works however, as soon as i add this:

addAndroidDownloads : {
         useDownloadManager : true
 }

i get the following error : RNFetchBlob request error: TypeError: expected dynamic type 'string', but had type object'null

My code is below in case there's a mistake.
React Native version : 0.46.4
RN Fetch Blob version : 0.10.6

Snippet :

async _downloadFile () {
    await RNFetchBlob.fetch('GET', Global.baseUrl+'/'+this.file.webPath , {
        authorization : Global.appToken,
	addAndroidDownloads : {
            "useDownloadManager" : true
        }
    })
    .then(async(res) => {
        console.log('file downloaded');
    })
    .catch((err) => {
        console.log('error DLL : ', err.message);
    });
}

Thanks by advance, really nice library by the way it helped me a lot :)

@lll000111
Copy link
Contributor

lll000111 commented Aug 16, 2017

For the record, that error message probably comes from this location, at least that's the only place I found :

https://github.com/wkh237/react-native-fetch-blob/blob/master/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java#L431

You can find a lot of similar questions about the same kind of error if you google (link)

Apparently you have an object (null) where a string is expected. Yes, the question is where :-)

@centotaure Just an aside, there is no need to declare the first then() function as async - you don't use await, so it is useless.

@RiusmaX
Copy link

RiusmaX commented Sep 8, 2017

Hi, did you find a solution ? I have the same problem :/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.