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 771 forks source link

Error: RNFetchBlob request error: Value for head cannot be cast from ReadableNativeMap to Stringnull #747

Open droplessjake opened 2 years ago

droplessjake commented 2 years ago

I've just started receiving this error, my function always worked fine previously and I'm not sure what changed with RNFetchBlob.

Can anyone explain why this might be?

const _path = this.getPath(path);
    const _data = JSON.stringify(data);
    const _headers = {
      ...this.service.defaults.headers,
      Accept: 'application/json',
      'Content-Type': 'application/json',
    };

    RNFetchBlob.fetch('POST', _path, _headers, _data).then((response) => {
      const filepath = `${RNFetchBlob.fs.dirs.DocumentDir}/invoice_${data.code}.pdf`;

      // Write file
      RNFetchBlob.fs.writeFile(filepath, response.data, 'base64');

      // Open file
      if (isIOS) {
        RNFetchBlob.ios.previewDocument(filepath);
      } else {
        RNFetchBlob.android.actionViewIntent(filepath, 'application/pdf');
      }
    });
retyui commented 2 years ago

This module is unmentionable ⚠️! please use fork: https://github.com/RonRadtke/react-native-blob-util