【发布时间】:2018-09-27 08:47:59
【问题描述】:
我正在尝试使用fetch 执行发布请求。
我的请求如下所示:
fetch(RequestURL,
{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body:
"param1=" + this.state.variable1 +
"param2=" + this.state.variable2 +
"param3=" + this.state.variable3 +
"param4=" + variable1+
"param5=" + variable2+
"param6=" + variable3
})
.then(res => res.json())
.then(obj => {
callback(obj)
})
.catch((error) => {
//Do some stuff.
})
requestURL 可能类似于 www.example.com\file\example.php
我已经尝试过这里建议的解决方案:
How can i pass POST parameters in fetch request? - React Native 这对我不起作用。我只是错过了什么,还是因为我使用 JSON 作为响应?
【问题讨论】:
标签: json react-native post parameters fetch