title: Express parse file sent with Javascript Fetch API
body: <p>I'm making an app which consumes an API I wrote, thing is that, I need the client to send an image to the API and then save it server-side, I successfully sent an image using a file input and the following script:</p>
  <pre class="lang-js prettyprint-override"><code>      const upload = _ =&gt; {
          let form = new FormData();
          form.append(&quot;file&quot;, document.getElementById(&quot;my-file-selector&quot;).files[0])
          fetch('http://localhost:3377/me/uploadPfp', {
            method: 'POST',
            headers: {
                &quot;Authorization&quot;: &quot;&lt;%= locals.user.token %&gt;&quot;,
                &quot;Content-Type&quot;: &quot;application/x-www-form-urlencoded&quot;
            },
            body: form,
            }).then(
              response =&gt; response.json()
            ).then(
              success =&gt; console.log(success)
            ).catch(
              error =&gt; console.log(error)
            );
        };
  </code></pre>
  <p>Server-side it seems to work, but I'm unable to save it using <code>fs.writeFile()</code>, it returns this error:</p>
  <pre><code>TypeError [ERR_INVALID_ARG_TYPE]: The &quot;data&quot; argument must be of type string or an instance of Buffer, TypedArray, or DataView.
  </code></pre>
  <p>But when I console.log the received file, this happens:
  <a href="https://i.stack.imgur.com/mSZqZ.png" rel="nofollow noreferrer">Receipt Image</a></p>