Skip to content

Instantly share code, notes, and snippets.

@luisnaranjo733
Created April 24, 2017 01:47
Show Gist options
  • Save luisnaranjo733/556535d2d3af89b7c69d3a74c8fcee9a to your computer and use it in GitHub Desktop.
Save luisnaranjo733/556535d2d3af89b7c69d3a74c8fcee9a to your computer and use it in GitHub Desktop.
How to make POST requests in JS
let data = new FormData();
data.append('note', 'new note value yo!');
let youth_visit_id = 1;
let url = `/api/visit/${youth_visit_id}/edit-note/`;
fetch(url, {
method: 'POST',
body: data
}).then(response => {
console.log('response');
console.log(response);
console.log(`Status code: ${response.status}`)
}).catch(ex => {
console.log('exception');
console.log(ex);
console.log(`Status code: ${response.status}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment