title: Possible Unhandled Promise Rejection (id: 0) React Native
body: <p>I am trying to upload files to AWS S3 bucket from my react native app but I get this error -&gt;
  <strong>Possible Unhandled Promise Rejection (id: 0)</strong>
  Here is the code:</p>
  <pre><code>import { View, Text, StyleSheet, TouchableOpacity } from 'react-native'
  import DocumentPicker from 'react-native-document-picker';
  import { RNS3 } from 'react-native-aws3';
  import Colors from '../constants/Colors';
  
  const Upload = (props) =&gt; {
  
      async function openDocumentFile() {
          try {
              const res = await DocumentPicker.pickSingle({
                  type: [DocumentPicker.types.allFiles],
              });
              console.log(
                  res.uri,
                  res.name,
                  res.type,
                  res.size
              );
              const file = {
                  uri: res.uri,
                  name: res.name,
                  type: res.type,
              }
              const options = {
                  keyPrefix: &quot;uploads/&quot;,
                  bucket: '',
                  region: 'ap-south-1',
                  accessKey: '',
                  secretKey: '',
                  successActionStatus: 201
              }
              RNS3.put(file, options)
              .then(response =&gt; {
                  if (response.status !== 201){
                      console.log(response.status);
                    throw new Error(&quot;Failed to upload image to S3&quot;);
                  }
                  console.log(response.body);
              });
          }
          catch (err) {
              if(DocumentPicker.isCancel(err)) {
                  console.log(&quot;user cancelled&quot;);
              }
              throw err;
          }
      }
  
      return (
          &lt;View style={styles.view}&gt;
              &lt;TouchableOpacity style={styles.button} onPress={openDocumentFile}&gt;
                  &lt;Text style={styles.text}&gt;Upload Documents&lt;/Text&gt;
              &lt;/TouchableOpacity&gt;
          &lt;/View&gt;
      )
  }
  
  export default Upload;
  
  const styles = StyleSheet.create({
      view: {
          flex: 1,
          justifyContent: 'center',
          alignItems: 'center',
      },
      button: {
          justifyContent: 'center',
          alignItems: 'center',
          color: Colors.white,
          padding: 10,
          borderColor: Colors.primary,
          borderWidth: 1,
      },
      text: {
          color: Colors.primary,
      }
  })
  </code></pre>
  <p>Here is the output I get which shows that the file is correctly selected but there is error in the code to upload the file to AWS-S3:</p>
  <pre><code>LOG content://com.android.providers.downloads.documents/document/msf%3A31 helloWorld.jpeg image/jpeg 26150
  LOG  400
  WARN  Possible Unhandled Promise Rejection (id: 0):
  Error: Failed to upload image to S3
  </code></pre>
  <p>I checked other questions and answers, but I didn't find a solution. How can I solve this error?</p>