I have a selection where the types of requests seem to be changing, which will ruin my post. I provide the main form (only one field). Here is a sample.
handleSubmit(event, data) {
event.preventDefault();
console.log("SUBMIT STATE::", this.state.value);
return (
fetch("//localhost:5000/api/values/dui/", {
method: "post",
mode: 'no-cors',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({
name: this.state.value,
})
}).then(response => {
if (response.status >= 400) {
this.setState({
value: 'no greeting - status > 400'
});
throw new Error('no greeting - throw');
}
return response.text()
}).then(data => {
var myData = JSON.parse(data);
this.setState({
greeting: myData.name,
path: myData.link
});
}).catch(() => {
this.setState({
value: 'no greeting - cb catch'
})
})
);
}
But when I look at this, the content-type fiddler now has "content-type: text / plain; charset = UTF-8". Here is the raw violinist:
POST http://localhost:5000/api/values/dui/ HTTP/1.1
Host: localhost:5000
Connection: keep-alive
Content-Length: 16
accept: application/json
Origin: http://evil.com/
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
content-type: text / plain; charset = UTF-8 Referer: http: // localhost: 3000 / Accept-Encoding: gzip, deflate, br Accept-Language: en-US, en; q = 0.8
{"name":"molly"}
In the DOM Inspector, I just see:
POST http: // localhost: 5000 / api / values / dui / 415 (Unsupported media type)
, "accept" - , "content-type". , . .