Skip to content

Instantly share code, notes, and snippets.

@jpbecotte
Last active September 14, 2018 14:43
Show Gist options
  • Save jpbecotte/79ca77d399e42ba14436d9d22be78e70 to your computer and use it in GitHub Desktop.
Save jpbecotte/79ca77d399e42ba14436d9d22be78e70 to your computer and use it in GitHub Desktop.
function sendData(url, data) {
  const formData = new FormData();

  for (let name in data) {
    formData.append(name, data[name]);
  }

  fetch(url, {
    method: 'POST',
    body: formData
  }).then(function (response) {
     ...
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment