title: React Native: Possible unhandled promise rejection (id: 0) TypeError: Network request failed
body: <p>I'm getting the following error: Possible unhandled promise rejection (id:0): Network request failed.
  <a href="https://i.stack.imgur.com/VYntO.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>I am trying to convey a review with text and a picture in firebase. In ReviewsScreen.js display and acceptance of data is implemented, in Fire.js processing and sending. I think somewhere in Fire.js the error lies but I have no ideas what the problem is</p>
  
  <p>ReviewsScreen.js</p>
  
  <pre><code>import React, { Component } from 'react';
  import {
    StyleSheet,
    View,
    TouchableOpacity,
    Text,
    SafeAreaView,
    Image,
    TextInput,
   SafeAreaViewBase
  } from 'react-native';
  import Icon from 'react-native-vector-icons/Ionicons'
  import {h, w} from '../../constants'
  import Fire from '../../Fire'
  import ImagePicker from 'react-native-image-picker';
  
  
  const options = {
    title: 'Select photo',
  };
  
  export default class ReviewsScreen extends Component {
    state = {
      text: '',
      image: null
    }
  
  pickImage = () =&gt; ImagePicker.showImagePicker(options, (response) =&gt; {
  console.log('Response = ', response);
  
  if (response.didCancel) {
    console.log('User cancelled image picker');
  } else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  } else {
    // You can also display the image using data:
    // const source = { uri: 'data:image/jpeg;base64,' + response.data };
  
    this.setState({
      image: response.uri
    });
  }
    });
  
    handleReview = () =&gt; {
  Fire.shared.addReview({text: this.state.text.trim(), localUrl: this.state.image}).then(ref =&gt; {
    this.setState({text: '', image: null})
    this.props.navigation.goBack()
  }).catch(error =&gt; {
    alert(error)
  })
    }
  
    render() {
  return (
    &lt;SafeAreaView style={styles.container}&gt;
      &lt;View style={styles.header}&gt;
        &lt;TouchableOpacity onPress={() =&gt; this.props.navigation.goBack()}&gt;
          &lt;Icon name='md-arrow-back' size={24} color='blue'/&gt;
        &lt;/TouchableOpacity&gt;
        &lt;TouchableOpacity onPress={this.handleReview}&gt;
          &lt;Text style={{fontWeight: '500'}}&gt;Добавить&lt;/Text&gt;
        &lt;/TouchableOpacity&gt;
      &lt;/View&gt;
  
      &lt;View style={styles.inputContainer}&gt;
        &lt;Image source={require('./img/avatar.jpg')} style={styles.avatar}/&gt;
        &lt;TextInput
          autoFocus={true}
          multiline={true}
          numberOfLines={1}
          style={{flex: 1}}
          placeholder='Нам важно ваше мнение!'
          onChangeText={text =&gt; this.setState({ text })}
          value={this.state.text}
        &gt;
        &lt;/TextInput&gt;
      &lt;/View&gt;
  
      &lt;TouchableOpacity style={styles.photo} 
        onPress={this.pickImage}&gt;
        &lt;Icon name='md-camera' size={32} color="#D8D9D8"&gt;&lt;/Icon&gt;
      &lt;/TouchableOpacity&gt;
  
      &lt;View syle={{marginHorizontal: 32, marginTop: 32, height: 150}}&gt;
        &lt;Image source={{uri: this.state.image}} style={{ marginTop: 32, alignSelf: 'center', width: '50%', height: '50%'}} /&gt;
      &lt;/View&gt;
    &lt;/SafeAreaView&gt;
      )
    }
  }
  </code></pre>
  
  <p>Fire.js </p>
  
  <pre><code>import firebaseConfig from './config'
  import firebase from 'firebase'
  
  class Fire {
    constructor() {
        firebase.initializeApp(firebaseConfig);
    }
  
  addReview = async ({ text, localUri }) =&gt; {
    const remoteUri = await this.uploadPhotoAsync(localUri);
  
    return new Promise((res, rej) =&gt; {
        this.firestore
            .collection("reviews")
            .add({
                text,
                uid: this.uid,
                timestamp: this.timestamp,
                image: remoteUri
            })
            .then(ref =&gt; {
                res(ref);
            })
            .catch(error =&gt; {
                rej(error)
            });
    });
    };
  
  uploadPhotoAsync = async uri =&gt; {
    const path = `photos/${this.uid}/${Date.now()}.jpg`;
  
    return new Promise(async (res, rej) =&gt; {
        const response = await fetch(uri);
        const file = await response.blob();
  
        let upload = firebase
            .storage()
            .ref(path)
            .put(file);
  
        upload.on(
            "state_changed",
            snapshot =&gt; {},
            err =&gt; {
                rej(err);
            },
            async () =&gt; {
                const url = await upload.snapshot.ref.getDownloadURL();
                res(url);
            }
        );
    });
  };
  
  get firestore() {
     return firebase.firestore();
  }
  
  get uid() {
      return (firebase.auth().currentUser || {}).uid;
  }
  
  get timestamp() {
      return Date.now();
  }
  }
  
  Fire.shared = new Fire();
  export default Fire;
  </code></pre>