【发布时间】:2019-04-01 22:39:31
【问题描述】:
我试图使用 promise.all 进行多个 api 调用,但由于某种原因它抛出了以下错误
TypeError: # is not iterable
我的 Promise 相当简单(这可能是我第二次使用 Promise.all)
componentWillMount() {
const id = this.props.location.pathname
let axiosHome = axios.get('/home')
let axiosUserData = axios.get("/profile/" + id)
Promise.all(axiosHome, axiosUserData).then(response => {
console.log(response)
}).catch(error => {
console.log(error)
})
}
问题:知道为什么我会收到此错误吗?另外,有人能解释一下我们什么时候用resolve关键字和promise吗?
【问题讨论】:
标签: javascript ajax reactjs promise es6-promise