var formData = new FormData();
formData.append('var', 'value');
fetch(url,
{
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8;'
},
body:formData
}
)
.then(data => {
if (data.ok) {
return data.json()
} else {
return Promise.reject(data)
}
})
.then(data => console.log(data))
.catch(() => {
console.log('err');
}
);