我面临以下问题与承诺链
我有这一系列的承诺,我根据数据类型设置了一个将要执行的变量
let an = try jsondecoder.decode([Annotations].self, from: dataa!)
jsonString[{"shapes":[{},{}],"imageiid":"IM0"},{"shapes":[],"imageiid":"IM1"},{"shapes":[],"imageiid":"IM2"}]
在这种情况下,if (data.type === 'type1') {
actionToExecute = action1;
resultToExecute = result1;
resultMsg = "result1";
} else {
actionToExecute = action2;
resultToExecute = result2;
resultMsg = "result2";
}
return actionToExecute(comment)
.then(() => {
return resultToExecute(data.id)
})
.then((response) => {
....
}
为resultoToExecute
action1
但是,在承诺链的响应中,我得到的不是执行arrown函数,而是函数本身
Application Installer: Microsoft database engine 2010 not available under pre-requisites
as,todo action1: (id) => {
return (dispatch, getState) => {
return api.fetchItems(id)
.then((response) => {
let action = {
'id': id,
'items': response
}
dispatch({
type: 'UPDATE-ITEMS',
action
})
})
因此可以进行API调用,并且reducer执行预期的操作。
知道我做错了吗?
注意:很抱歉,如果代码含糊不清,但我无法提供太多关于代码的客户代码
Edit1:现在,我觉得很蠢
答案 0 :(得分:0)
我刚刚意识到自己的错误,感谢Felix Kling我刚刚看到,确实,我没有回复承诺,只是一个简单的功能