title: How to upload image to node js server from react native (expo) using fetch
body: <p>I am not receiving data on the server side. Sometimes I  get data as an object. I have tried different ways but the image upload gets failed. Below is my code. I have tried different method but the result was the same image folder remain empty as am using multer middleware</p>
  <p>Image is getting displayed using this snippet</p>
  <pre class="lang-js prettyprint-override"><code>&lt;TouchableHighlight
    style={[
      styles.profileImgContainer,
      { borderColor: &quot;#4632a1&quot;, borderWidth: 1 },
    ]}
    onPress={openImagePickerAsync}
  &gt;
    &lt;Image source={{ uri: selectedImage.localUri }} style={styles.thumbnail} /&gt;
  &lt;/TouchableHighlight&gt;
  </code></pre>
  <p>This is the Image Picker Section</p>
  <pre class="lang-js prettyprint-override"><code>function PickImage() {
    let [selectedImage, setSelectedImage] = useState(&quot;&quot;);
    let openImagePickerAsync = async () =&gt; {
      let permissionResult =
        await ImagePicker.requestMediaLibraryPermissionsAsync();
  
      if (permissionResult.granted === false) {
        alert(&quot;Permission to access camera roll is required!&quot;);
        return;
      }
  
      let pickerResult = await ImagePicker.launchImageLibraryAsync();
      if (pickerResult.cancelled === true) {
        return;
      }
  
      setSelectedImage({ localUri: pickerResult.uri });
    };
  }
  </code></pre>
  <p>Fetch API Call</p>
  <pre class="lang-js prettyprint-override"><code>async function upload() {
    const data = new FormData();
    data.append(&quot;image&quot;, {
      uri: selectedImage.uri,
      name: selectedImage.title,
      type: selectedImage.type,
    });
  
    const setting = {
      method: &quot;POST&quot;,
      headers: {
        &quot;Content-Type&quot;: &quot;multipart/form-data;&quot;,
      },
      body: data,
    };
    try {
      const fetchResponse = await fetch(url, setting);
      const data = await fetchResponse.json();
      alert(data);
    } catch (e) {
      alert(e);
    }
  }
  </code></pre>
  <p>Server-Side Code</p>
  <pre class="lang-js prettyprint-override"><code>app.post(&quot;/users&quot;, upload.single(&quot;image&quot;), async (req, res) =&gt; {
    console.log(req.body.file);
    console.log(req.body);
    const img = req.body.image;
    if (!img) {
      console.log(&quot;no image&quot;);
    }
  
    res.send({ congrats: &quot;data recieved&quot; });
  });
  </code></pre>