【问题标题】:TypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than is not a functionTypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than 不是函数
【发布时间】: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


    【解决方案1】:

    promise 链有一个错字,应该是 then 而不是 than,所以正确的实现应该是这样的

      componentDidMount() {
        axios.get(`https://jsonplaceholder.typicode.com/posts`)
          .then((response) => {
            this.setState({ posts: response.data });
          })
      }
    

    【讨论】:

      猜你喜欢
      • 2019-04-06
      • 1970-01-01
      • 2020-06-29
      • 2020-06-17
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      • 2021-06-05
      • 2019-10-03
      相关资源
      最近更新 更多