title: React Native: setState doesn't work when calling try-catch function
body: <p>I tried to call APP with this code imported from another file and it worked fine:</p>
  
  <pre><code>import FormData from 'FormData';
  import AsyncStorage from '@react-native-community/async-storage';
  
  let formData = new FormData();
  
  formData.append('userId', '1'); // &lt; this is what I want to change
  formData.append('key', '***'); //my key
  
   export function getScoreFromAPI () {
     return fetch('https://www.globalfidelio.com/gfn_arcol/api/transaction.php',{
                   method : 'POST',
                   headers : {
                     'Accept': 'application/json',
                     'Content-Type': 'multipart/form-data'
                   },
                   body : formData
               } )
         .then((response) =&gt; {
            return response.json()
         })
      .catch((error) =&gt; console.log("l'erreure est:  " + error))
   }
  </code></pre>
  
  <p>but now I want to change my userId from 1 to an constante from Asyncstorage, so I decide to change my code to this:</p>
  
  <pre><code>  constructor(props) {
        super(props)
        this.state = { infos: [], userId: '' }
    }
  
    componentWillMount() {
      this.getScoreFromAPI().then(data =&gt; {
        this.setState({ infos: data })
      });
      console.log(this.state.infos);
      AsyncStorage.getItem(USERID_STORED)
      .then((data) =&gt; {
          if (data) {
             this.setState({userId:data})
          }
      });
    }
    async getScoreFromAPI() {
        let formData = new FormData();
        formData.append('userId', this.state.userId);
        formData.append('key', '***'); //my key
      try {
        let response = await fetch('https://www.globalfidelio.com/gfn_arcol/api/transaction.php',{
          method: 'POST',
          headers: {
            'Accept': 'application/json',
            'Content-Type': 'multipart/form-data'
          },
          body: formData
        })
        let res = await response.json();
  
    } catch(error) {
        console.warn("errors are " + error);
    }
  };
  </code></pre>
  
  <p>with a try-catch function but when I call <code>getScoreFromAPI()</code> in <code>ComponentWillMount()</code> I can't setState with received data, I still have an empty array in info:[]</p>
  
  <p><strong>my questions:</strong></p>
  
  <p>how can I replace '1' in userId by a value in asyncstorage in the first file ?</p>
  
  <p>if it isn't possible, what I have do to setState info: [] with my data reveived</p>