title: Convert a curl request into NodeJS request
body: <p>I am currently working on an API which gives an example of request with curl like this:</p>
  
  <pre><code>curl -v -H "Accept-Token: mysecret" -H "User-Token: my_user" \
       -F "filename=@my_photo.jpg" \
       -F "face_detection={\"fast\" : true}" \
       -F "age_detection={\"something\" : true}" \
       127.0.0.1:8080/vision_batch
  </code></pre>
  
  <p>When I do such a request this is what is printing netcat:</p>
  
  <pre><code>POST /vision_batch HTTP/1.1
  Host: 127.0.0.1:9000
  User-Agent: curl/7.47.0
  Accept: */*
  Accept-Token: test_token
  User-Token: test
  Content-Length: 635202
  Expect: 100-continue
  Content-Type: multipart/form-data; boundary=------------------------a32bed4123bace7d
  
  --------------------------a32bed4123bace7d
  Content-Disposition: form-data; name="filename"; filename="photo.png"
  Content-Type: application/octet-stream
  &lt;binary_content&gt;
  --------------------------a32bed4123bace7d
  Content-Disposition: form-data; name="face_detection"
  
  {}
  --------------------------a32bed4123bace7d
  Content-Disposition: form-data; name="qr_recognition"
  
  {}
  --------------------------a32bed4123bace7d--
  </code></pre>
  
  <p>But I don't how to translate this multiple forms in NodeJS. I am currently doing multiple requests for each form but I have to send the image each time...</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>function getOptions(buffer, service) {
    return {
      url: 'http://127.0.0.1:9001/' + service,
      headers: headers,
      method: 'POST',
      formData: {
        filename: buffer,
        face_recognition: [],
        age_detection: []
      }
    }
  }
  
  var res_json = {};
  request(getOptions(buffer, 'face_recognition'), function(error, response, body) {
  });
  </code></pre>
  
  <p>The problem is that the API is returning me <code>no args</code>. And effectively, netcat is printing the following:</p>
  
  <pre><code>POST /vision_batch HTTP/1.1
  Accept-Token: YE6geenfzrFiT88O
  User-Token: ericsson_event
  host: 127.0.0.1:9000
  content-type: multipart/form-data; boundary=--------------------------648089449032824937983411
  content-length: 663146
  Connection: close
  
  ----------------------------648089449032824937983411
  Content-Disposition: form-data; name="filename"
  Content-Type: application/octet-stream
  &lt;binary_content&gt;
  ----------------------------648089449032824937983411--
  </code></pre>
  
  <p>The problem is that I don't how to change the field formData in the request...</p>