向服务器发送 Post 数据时出错
Getting error sending Post data to server
我正在通过api向服务器发送数据。但是我在响应时收到错误。
下面是我的代码
fetch('http://35.196.195.208/SaveRecommendAppDetails', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
UserId:"23",
ClientId:"2",
Name: "Paras",
Email: "Paras@gmail.com",
Phone: "9876543210",
CreatedUserId:"23" ,
Company: "Brill Infosystem"})
})
.then((response) =>JSON.stringify(response.json()))
.then((responseJson) =>{console.log( "==========response=========" + responseJson) })
.catch((err) => { console.log("==========error=========" + err); });
}
错误是:
{ "_40":0,"_65":0,"_55":null,"_72":null }
{ "_40":0,"_65":0,"_55":null,"_72":null }
是 console.log
一个 Promise
对象时得到的结果。 response.json()
returns 一个 Promise
,所以你不能只是 JSON.stringify()
它。删除对 JSON.stringify()
.
的调用
我正在通过api向服务器发送数据。但是我在响应时收到错误。
下面是我的代码
fetch('http://35.196.195.208/SaveRecommendAppDetails', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
UserId:"23",
ClientId:"2",
Name: "Paras",
Email: "Paras@gmail.com",
Phone: "9876543210",
CreatedUserId:"23" ,
Company: "Brill Infosystem"})
})
.then((response) =>JSON.stringify(response.json()))
.then((responseJson) =>{console.log( "==========response=========" + responseJson) })
.catch((err) => { console.log("==========error=========" + err); });
}
错误是: { "_40":0,"_65":0,"_55":null,"_72":null }
{ "_40":0,"_65":0,"_55":null,"_72":null }
是 console.log
一个 Promise
对象时得到的结果。 response.json()
returns 一个 Promise
,所以你不能只是 JSON.stringify()
它。删除对 JSON.stringify()
.