title: Javascript using fetch to POST multiple BODY types
body: <p>I am trying to use a fetch to POST data to a remote server that will run a PHP script. When I try the fetch with just the formData, it works. However, when I add the API as a second post variable into the POST, it throws an error <code>SyntaxError: Unexpected token a in JSON at position 0</code>. I am thinking since the API is not actually formdata, am I not allowed to append it as formdata? Also, are we able to POST two types in the BODY, let's say formdata and text?</p>
  
  <pre><code>function exeCtCoreAPI(api) {
      var url = "executetest.php";
      console.log ("this is the URL: " + url); // this is correct
      var formData = new FormData();
      formData.append('gateway', gatewayName);  
      formData.append('api', api);    
      console.log ("these are the post data: " + api + " " + gatewayName); //these are correct
      fetch(url,
      {
          method: "POST",
          body: formData
      })
      .then(handleErrors)
      .then(response =&gt; response.json())
      .then(json =&gt; {
          //do something with the json
          console.log("This is the returned params: " + JSON.stringify(json));
      })
      .catch(error =&gt; console.log(error));
  }
  
  
  exeCtCoreAPI("myAPI");
  </code></pre>
  
  <p>It seems to throw the error before it hits the php script, cause when I dump the POST in the PHP I don't see anything echoed out.</p>
  
  <p>Not sure what I'm doing wrong here...</p>