Open wgh970312 opened 4 years ago
使用redux dispatch 一个Taro.request(),会报Actions must be plain objects. Use custom middleware for async actions.
// login.jsx this.props.dispatch(login({username: 'username', password: '123456', code: '123456' })) // user.js //reducer export function login(data){ return dispatch => { console.log(data) // dispatch({type: 'login', payload: true}) return dispatch(_login(data)).then(res => { console.log(res) }) } } // api.js export function login(data) { return Taro.request({ url: `${api}/backend/login/login`, method: 'POST', data }).then(res => { return res.data }) }
可以正常dispatch一个promise
Taro CLI 2.2.1 environment info: System: OS: macOS 10.15.4 Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.16.2 - /usr/local/bin/node Yarn: 1.22.4 - ~/.yarn/bin/yarn npm: 6.14.4 - /usr/local/bin/npm npmPackages: @tarojs/components: 2.2.1 => 2.2.1 @tarojs/components-qa: 2.2.1 => 2.2.1 @tarojs/mini-runner: 2.2.1 => 2.2.1 @tarojs/redux: 2.2.1 => 2.2.1 @tarojs/redux-h5: 2.2.1 => 2.2.1 @tarojs/router: 2.2.1 => 2.2.1 @tarojs/taro: 2.2.1 => 2.2.1 @tarojs/taro-alipay: 2.2.1 => 2.2.1 @tarojs/taro-h5: 2.2.1 => 2.2.1 @tarojs/taro-qq: 2.2.1 => 2.2.1 @tarojs/taro-quickapp: 2.2.1 => 2.2.1 @tarojs/taro-swan: 2.2.1 => 2.2.1 @tarojs/taro-tt: 2.2.1 => 2.2.1 @tarojs/taro-weapp: 2.2.1 => 2.2.1 @tarojs/webpack-runner: 2.2.1 => 2.2.1 eslint-config-taro: 2.2.1 => 2.2.1 eslint-plugin-taro: 2.2.1 => 2.2.1 nerv-devtools: ^1.5.5 => 1.5.6 nervjs: ^1.5.5 => 1.5.6 stylelint-config-taro-rn: 2.2.1 => 2.2.1 stylelint-taro-rn: 2.2.1 => 2.2.1
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
问题描述
使用redux dispatch 一个Taro.request(),会报Actions must be plain objects. Use custom middleware for async actions.
期望行为
可以正常dispatch一个promise
报错信息
系统信息
Taro CLI 2.2.1 environment info: System: OS: macOS 10.15.4 Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.16.2 - /usr/local/bin/node Yarn: 1.22.4 - ~/.yarn/bin/yarn npm: 6.14.4 - /usr/local/bin/npm npmPackages: @tarojs/components: 2.2.1 => 2.2.1 @tarojs/components-qa: 2.2.1 => 2.2.1 @tarojs/mini-runner: 2.2.1 => 2.2.1 @tarojs/redux: 2.2.1 => 2.2.1 @tarojs/redux-h5: 2.2.1 => 2.2.1 @tarojs/router: 2.2.1 => 2.2.1 @tarojs/taro: 2.2.1 => 2.2.1 @tarojs/taro-alipay: 2.2.1 => 2.2.1 @tarojs/taro-h5: 2.2.1 => 2.2.1 @tarojs/taro-qq: 2.2.1 => 2.2.1 @tarojs/taro-quickapp: 2.2.1 => 2.2.1 @tarojs/taro-swan: 2.2.1 => 2.2.1 @tarojs/taro-tt: 2.2.1 => 2.2.1 @tarojs/taro-weapp: 2.2.1 => 2.2.1 @tarojs/webpack-runner: 2.2.1 => 2.2.1 eslint-config-taro: 2.2.1 => 2.2.1 eslint-plugin-taro: 2.2.1 => 2.2.1 nerv-devtools: ^1.5.5 => 1.5.6 nervjs: ^1.5.5 => 1.5.6 stylelint-config-taro-rn: 2.2.1 => 2.2.1 stylelint-taro-rn: 2.2.1 => 2.2.1