无法在React JS中以JSON格式发送数据

时间:2018-08-13 21:11:59

标签: json reactjs fetch

您好,下面的示例是我的代码,我想知道为什么不能仅以json格式发送数据并且我收到响应的失败消息,所有内容都已导入并且我正在使用reactjs

fetchData = async () => {
  const api_call = await fetch("my ur here", {
    method: "Post",
    dataType: "JSON",
    headers: { "Accept": "application/json","Content-Type": "application/json"},
    body: Stringify({"Country": this.state.Country,"Mobile": this.state.Mobile})
  });
    const response = await api_call;
    this.setState({ data : response } );
    console.log('log : ',this.state.data);
}

0 个答案:

没有答案