Home > Software engineering >  TypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than is not a function
TypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than is not a function

Time:11-30

i am new in react redux i am getting an error like as "TypeError: axios__WEBPACK_IMPORTED_MODULE_1___default.a.get(...).than is not a function" please help here is the code that i am using.

enter image description here

CodePudding user response:

There is a typo with promise chaining, it should be then instead of than, so correct implementation should look like

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