【发布时间】:2019-09-13 22:47:45
【问题描述】:
我想将内容类型强制为 application/json 但我有一个模式“no-cors”,实际上内容类型的返回是:text/plain;charset=UTF-8 当我通过时它是一样的标题,所以我不知道该怎么做。
我已经尝试使用 fetch 或 Axios,URL 在 HTTP 中,我在本地工作,所以可能是问题所在? 我试过 Postman,效果很好。
fetch('http://link', {
method: 'POST',
credentials: 'include',
redirect: 'follow',
mode: 'no-cors',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"cluster_id" : [],
"surname" :["albert"],
"gender" :[],
}),
}).then((result) => {
this.setState({ allClient: result.data }, () => {
this.setState({ load: true })
console.log(this.state.allClient)
})
所以,我想要内容类型:application/json 而不是 Content-Type: text/plain;charset=UTF-8
【问题讨论】:
标签: reactjs post content-type