【发布时间】:2020-10-20 12:11:46
【问题描述】:
我是 react redux 的新手,我收到类似“WEBPACK_IMPORTED_MODULE_1___default.a.post(...).then(...).dispatch is not a function”的错误 请帮忙 这是我正在使用的代码
API 平均值 == http://localhost:8000/api/
index.js
import {API} from '../backend';
import axios from 'axios';
export const getdata = (todo) => {
return (dispatch) => {
axios.post(`${API}addtodo`)
.then(res => {
console.log(res)
})
.dispatch({
type : 'FETCH_TODO',
payload : todo
})
.catch(err =>{
console.log(err);
})
}
}
【问题讨论】:
标签: javascript reactjs react-redux react-hooks redux-thunk