title: How to pass POST parameters in fetch for uploading image to server in React Native?
body: <p>This is the code with I'm trying to send my image to server.   </p>
  
  <pre><code> postData = async () =&gt; {   
          var location = await AsyncStorage.getItem('location');        
          var path = await AsyncStorage.getItem('path');
          var post_type = await AsyncStorage.getItem('post_type');    
          var userId = await AsyncStorage.getItem('userID');
  
      const formData = new FormData();
  
  //I want to pass params in fetch but I don't know how to.     
  
         var params = JSON.stringify({ 
              "user": userId,
              "description": this.state.description,
              "location": location,
              "post_type": post_type,
            });
  
      const uriPart = path.split('.');
      const fileExtension = uriPart[uriPart.length - 1];
  
      formData.append('photo', {
          uri: path,
          name: `photo.${fileExtension}`,
          type: `image/${fileExtension}`,
      });
  
      fetch(strings.baseUri+"addPosts",{
          method: 'POST',
          headers: {
              'Content-Type': 'multipart/form-data',
            },
          body: formData,
        })
        .then((response) =&gt; response.json())
        .then((responseJson) =&gt; {
  
         alert(responseJson); // This gives me error JSON Parse error: Unexpected EOF
  
        })
        .catch((error) =&gt; {
            console.error(error);
        });    
    }
  </code></pre>
  
  <p>I want to pass my parameters in fetch. The parameters are params in my case. I want to send these parameters along with my image to server. Please help. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p><a href="https://i.stack.imgur.com/GXdp8.png" rel="nofollow noreferrer">this is when I used alert(JSON.stringify(response));</a></p>