title: Set State Inside Async Function in React Native(Expo)
body: <p>I am using Expo of React Native which i need to save the API Fetch response to state. </p>
  
  <p>My code is like this: </p>
  
  <pre><code>onPress={async () =&gt; {
  
                    if (this.camera) {
                      const options = { quality:0, base64: true};
                      let photo = await this.camera.takePictureAsync(options);
                        setTimeout(()=&gt;{     
                        fetch('https://c7pl8gkrj6.execute-api.ap-southeast-1.amazonaws.com/prod/rekog', {
                          method: 'POST',
                          headers: {
                            Accept: 'application/json',
                            'Content-Type': 'application/json',
                          },
                          body: JSON.stringify({
                            base64: photo['base64'],
                          }),
                        }).then((responseJson) =&gt; {  
                          this.setState({
                              response:responseJson
                              })
                          })
                          .catch((error) =&gt; {
                            console.error(error);
                          });
                          this.setState({captured:true})
                          }, 3000)
  
                    }
                  }}
  </code></pre>
  
  <p>I want to store the response in the state variable named 'response'. But When I want to display the response saved in state, it will render null. </p>
  
  <pre><code>if(this.state.captured){
          console.log(this.state.response)
          return(
            &lt;View style={styles.container}&gt;
          &lt;SectionList
            sections={[
              {title: 'response1', data: [this.state.response]}
            ]}
            renderItem={({item}) =&gt; &lt;Text style={styles.item}&gt;{item}&lt;/Text&gt;}
            renderSectionHeader={({section}) =&gt; &lt;Text style={styles.sectionHeader}&gt;{section.title}&lt;/Text&gt;}
            keyExtractor={(item, index) =&gt; index}
          /&gt;
        &lt;/View&gt;
          );
           }else{
             ...
  </code></pre>
  
  <p>Here, console.log(this.state.response) shows {} i.e null value. Is it the problem of async function which is not displaying the value saved in state.</p>