MULTI API CALLS

Asked by At

I am trying to make multiple API calls on componendDidMount and I keep getting back a typeError

cannot find property of 'then' undefined

How to solve this issue?

  componentDidMount() {


    //first API call to all the boards 
  API.getAllBoards()


  .then(res => {

    this.setState({

      boards: res.data
    }) 

    console.log(res.data);

    console.log("one");

  }).then()
  //second API CALL

  API.getPowder()

  .then(res => {

    this.setState({

    powder: res.data

    });

    console.log(res.data);

    console.log("two")

  });


  }

1 Answers

0
SatyaDash On

You should remove the 2nd then you have written in the First API call i.e. getAllBoards.