观看时,帖子的内容类型正在发生变化我有一个取其中的请求类型似乎正在改变它搞乱了我的职务。我提交我的基本表格(仅限一个字段)。这是抓取。作出反应 - 在获取提琴手
handleSubmit(event, data) {
//alert('A name was submitted: ' + this.state.value);
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'
})
})
);
}
但是,当我在提琴手内容类型看这是现在“内容类型:文本/无格式;字符集= UTF-8”。这里是原始的Fiddler:
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
内容类型:文本/无格式;字符集= UTF-8 的Referer:http://localhost:3000/ 接受编码:gzip,放气,BR 接受语言:EN-US,烯; q = 0.8
{"name":"molly"}
在DOM查看我只看到:
POST http://localhost:5000/api/values/dui/ 415(不支持的媒体类型)
我还发现奇怪的是,'接受'是小写以及'内容类型'。任何理由为什么发生这种情况。我还没有发现任何具体的搜索结果。