Skip to content

Instantly share code, notes, and snippets.

@soaxelbrooke
Created March 26, 2018 00:52
Show Gist options
  • Save soaxelbrooke/a85ee519dc773ae507a298624cdf291d to your computer and use it in GitHub Desktop.
Save soaxelbrooke/a85ee519dc773ae507a298624cdf291d to your computer and use it in GitHub Desktop.
Submitting form data with fetch in JavaScript
function postTagData(myUrl, documentId, fullText, tag, start, end) {
let form = new FormData();
form.set('document_id', documentId);
form.set('full_text', fullText);
form.set('region_start', start);
form.set('region_end', end);
return window.fetch(myUrl, {
method: 'POST',
body: form
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment