Javascript 如何在react redux中使用异步函数
我在React.js中使用Redux,这里是我的handleSubmit方法:Javascript 如何在react redux中使用异步函数,javascript,reactjs,asynchronous,redux,Javascript,Reactjs,Asynchronous,Redux,我在React.js中使用Redux,这里是我的handleSubmit方法: handleSubmit = async (e) => { e.preventDefault(); await this.props.createCoupon({ value: this.state.value, expiresDate: new Date(this.state.expiresDate) }); this.props.fetchC
handleSubmit = async (e) => {
e.preventDefault();
await this.props.createCoupon({
value: this.state.value,
expiresDate: new Date(this.state.expiresDate)
});
this.props.fetchCoupons();
}
从逻辑上讲,在CreateCouncil完成后,FetchCouncips函数将运行,这是可行的,但我在控制台中获取了
获取优惠券请求
在创建优惠券成功
之前和之后,这是怎么回事?尝试类似的方法
handleSubmit = async (e) => {
e.preventDefault();
await this.props.createCoupon();
this.props.fetchCoupons();
},
createCoupon(){
value: this.state.value,
expiresDate: new Date(this.state.expiresDate)
}