【发布时间】:2017-09-23 14:02:43
【问题描述】:
var formData = new FormData(loginRequestObject);
formData.append('userName', loginRequestObject.username);
formData.append('password', loginRequestObject.password);
formData.append('mobile', loginRequestObject.mobile);
formData.append('deviceid', deviceInfo.getDeviceId())
这是我正在提出的要求-
在身体部位
try{
const response = yield call(fetch, Url, {
method : 'POST',
headers : {
'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
'Content-Type' :'multipart/form-data, application/x-www-form-urlencoded; charset=utf-8'
},
body : formData
})
if(response.ok) {
const jsonResponse = yield response.text()
yield put(LoginActions.loginSuccess(jsonResponse))
} else {
const jsonResponse = yield response.text();
yield put(LoginActions.loginFailure(jsonResponse))
}
我要求发布数据,但我不能这样做,是什么原因?
【问题讨论】:
-
你的代码看起来没问题,你怎么看到它不起作用?它会发送一个 http 帖子吗?
-
这个调用函数是关于什么的?为什么不直接使用 ES6 fetch 将 fromData 发布到服务器?如果发生了什么事,你检查过你的网络标签吗?
-
当我使用发布时它告诉** type == null **。并且在我使用 `body:JSON.stringify(formData)` 时发生网络调用,但值将不正确。
标签: reactjs react-native ecmascript-6 redux-saga