Hello.

There is such a method:

sendMessage (data) { axios.post(`http://127.0.0.1:5000/messages`, { text: JSON.stringify(data) }) .then(response => { console.log(response) }) .catch(e => { console.log(e) }) } 

But on the server fulfills only OPTIONS.

 127.0.0.1 - - [03/Nov/2017 22:41:13] "OPTIONS /messages HTTP/1.1" 200 - 

When I send using httpie :

 http http://127.0.0.1:5000/messages text=HelloWorld 

That first executes OPTIONS , and then POST :

 127.0.0.1 - - [03/Nov/2017 22:41:13] "OPTIONS /messages HTTP/1.1" 200 - 127.0.0.1 - - [03/Nov/2017 22:52:45] "POST /messages HTTP/1.1" 201 - 

That is, everything is as it should be.

At first, I was thinking about CORS or a jamb on the backend, and asked a question on github, to which I received an answer that this is most likely an error on the client.

Thanks in advance for any help.

    1 answer 1

    I changed the Content-Type for all requests globally and it all worked. Initially, I used Content-Type: application / json, but for correcting axios and sending POST, I set Content-Type: application / x-www-form-urlencoded Good luck