我试图在componendDidMount上进行多个API调用,并且一直得到一个typeError。
找不到未定义的“那么”属性
如何解决这个问题?
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")
});
}发布于 2019-04-29 12:02:40
您应该删除第二个API,然后在第一个API调用(即getAllBoards )中编写。
https://stackoverflow.com/questions/55902200
复制相似问题