【发布时间】:2022-01-07 03:24:34
【问题描述】:
我是 react redux 的新手,我收到一个错误,例如“TypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than is not a function”请帮助这里是我正在使用的代码。
【问题讨论】:
标签: reactjs react-redux react-hooks axios react-router
我是 react redux 的新手,我收到一个错误,例如“TypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than is not a function”请帮助这里是我正在使用的代码。
【问题讨论】:
标签: reactjs react-redux react-hooks axios react-router
promise 链有一个错字,应该是 then 而不是 than,所以正确的实现应该是这样的
componentDidMount() {
axios.get(`https://jsonplaceholder.typicode.com/posts`)
.then((response) => {
this.setState({ posts: response.data });
})
}
【讨论】: