title: How to separate multipart/form-data with boudary in node.js
body: <p><a href="https://i.stack.imgur.com/0v7zG.png" rel="nofollow noreferrer">Contents of the message received form the HttpPost</a></p>
  
  <p>I have an Azure Function running on Node.js</p>
  
  <p>The message that arrives has a content-type with a specified boundary.</p>
  
  <pre><code>'content-type': 'multipart/form-data; 
  boundary=------------------------8bb0bdeb26804014' },
  </code></pre>
  
  <p>How can I obtain the object found in the RawRequest?</p>
  
  <pre><code>--------------------------8bb0bdeb26804014\r\nContent-Disposition: form data; name="rawRequest"\r\n\r\n
  
  {"slug":"submit\\/80705882093865\\/",
  "q1_nombres":"first":"textbox_sample0",
  "last":"textbox_sample1"},
  "q3_email":"john@example.com",
  "preview":"true"}\r\n
  </code></pre>
  
  <hr>
  
  <p>Edit1:</p>
  
  <p>So far Im doing this:</p>
  
  <pre><code>var parts = req.headers['content-type'].split('boundary=');
  var boundary = parts[1];
  context.log("Boundary: "+boundary);
  var splitBody = req.body.split( boundary );
  context.log("RawRequest: "+splitBody[8]);
  </code></pre>
  
  <p>But I would still have to work around this:</p>
  
  <pre><code>Content-Disposition: form-data; name="rawRequest"
  
  {"slug":"submit\/80705882093865\/",
  "q1_nombres":{"first":"textbox_sample0",
  "last":"textbox_sample1"},
  "q3_email":"john@example.com",
  "preview":"true"} --
  </code></pre>
  
  <p>And it seems very prone to break if I just start manipulating the string even further. </p>