Fetch returns path - but no file is downloaded #133
Description
I check and add permissions for read/write to external storage in using react-native-android-permissions at runtime. The following code returns the path but the image is not downloaded to the path.
componentWillMount() {
var url = 'http://SKM:5000/user.png';
let dirs = RNFetchBlob.fs.dirs
RNFetchBlob
.config({
path : dirs.DocumentDir + '/user.png',
fileCache : true
}
)
.fetch( 'GET', url )
.then((res) => {
console.log( res );
return(res.path);
})
.then(this.onAfterLoad) // Success callback registration
.catch(function(e) { // Failure callback registration
alert('Failure fetching data');
console.log(e)
});
}
On success set the state --
onAfterLoad = (resp) => {
this.setState({
data : resp
});
};
Use in render as follows
<Image style={styles.mark}
source={this.state.data}
defaultSource={require('../images/default.png')} />
What am I missing ?