I
I
Ilya Kochkin2020-04-19 15:04:12
JavaScript
Ilya Kochkin, 2020-04-19 15:04:12

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');
                            }
                    );

and such data is sent to the server
Yr1MG0HM1Eg.jpg
how do I send normal data of the form key : value
3RsqcEaMq54.jpg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question