此功能不会触发第一个“ then”。有人可以告诉我为什么吗?
该功能有效,但“然后”不会触发。
export function changeData(url, type, table, message, params, action) {
return (dispatch) => {
const request = Server.get(url, { params: { table: table, params: params }});
return request.then(() => { // <- This then doesn't work
console.log('I'm not being fired')
Promise.all([
dispatch({ type: type, payload: params })
]).then(() => {
if (action) {return dispatch(action())}
}).catch((error) =>
console.log(error)
)
)
}
}
这是从上述函数调用的请求:
_server.get(`/insertSelect`, (req, res) => {
let table = req.query.table
let params = req.query.params
let select = true
consoleLog('insert', table, params)
DefaultSQL.insert(table, params, select).then(response => {
res.json(response)
})
})
这就是我叫changeData的方式:
export const updateCliente = params =>
dbActions.changeData(
'insertUpdate',
SAVE_CLIENTE,
`erp_ClientesEFornecedores`,
'Cliente salvo com sucesso',
params
)
我的调度来自redux