Answer the question
In order to leave comments, you need to log in
Need help using fetch POST - extra data when sending a post? why?
Hello, I have a view code
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');
}
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question