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

null is not an object (evaluating 'RNFetchBlob.DocumentDir') using Expo #516

Closed ghost closed 4 years ago

ghost commented 4 years ago

I'm using Expo and try to download files using react-native-fetch-blob

import RNFetchBlob from 'rn-fetch-blob';

RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png')
  .then((res) => {
    let status = res.info().status;
  })
  .catch((errorMessage, statusCode) => {
  })

There is an error occurs: null is not an object (evaluating 'RNFetchBlob.DocumentDir')

What i've already tried:

npm install --save react-native-fetch-blob
react-native link 
npm install --save react-native-fetch-blob
react-native link react-native-fetch-blob
var RNFetchBlob = require('rn-fetch-blob').default
RNFB_ANDROID_PERMISSIONS=true react-native link

How to fix this issue? Does rn-fetch-blob work with Expo?

Traviskn commented 4 years ago

https://github.com/joltup/rn-fetch-blob/issues/517#issuecomment-573483891

jopsyvarghese commented 4 years ago

You cannot use RNFetchBlob in an Expo managed project as it requires deep linking. Try using expo-file-system instead.