kreativan
8/11/2018 - 2:44 PM

Fetch API

JavaScrpt Fetch API Post Form Data

// data we will be sending
var formData = new FormData();
formData.append('name', 'John Doe');
formData.append('work', 'Web Developer');

fetch('www.example.com/api/', {
    method: 'POST',
    body:  formData
})
.then(function(response) {
       return response.json();
})
.then(function(response) {
	console.log(response);
});