reactjs - 未捕获的类型错误:_this.props.saveApp(...).then 不是函数
问题描述
// Component code
this.props.saveApp(values, data).then((result) => {
//do something
}).catch((error) => {
});
我正在使用反应还原
以下是我的行动
解决方案
您需要在您的操作中返回承诺,并且响应未在正确的位置返回。查看我的评论以了解我编辑的内容:
export function saveApp(appvalue, fdata) {
return dispatch => {
return request // You need to add the return here!!
.post(\'http://appplay.net:8082/api/v1/addFile\')
.send(fdata)
.then(function(res) {
// res.body, res.headers, res.status
console.log(res.body.data);
var downloadurl = res.body.data;
// console.log(values);
// this.saveApp( values, downloadurl );
var platfrom1 = (appvalue.Platform === "iOS")? "2" : "1";
var ref_newapp = db.ref().child("Apps");
var auto_id = ref_newapp.push();
auto_id.set({
"App_Icon": appvalue.appicon,
"App_Name": appvalue.appname,
"Download_URL": downloadurl,
"Is_Active": parseInt(appvalue.radiostatus, 10),
"Platform": parseInt(platfrom1, 10),
"Version" :appvalue.version
});
return res; // I think you want to return the res here!!
})
.catch(function(err) {
// err.message, err.response
});
}
}