// Component code
this.props.saveApp(values, data).then((result) => {
//do something
}).catch((error) => {
});
我正在使用react redux
以下是我的行动
答案 0 :(得分:0)
您需要在操作中返回承诺,并且不会在正确的位置返回响应。请参阅我的评论以了解我编辑的内容:
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
});
}
}