【发布时间】:2019-03-11 04:42:27
【问题描述】:
我刚看了一篇与 promise 相关的文章,无法理解我们如何通过 Promise.all 使用 Axios 进行多个 API 调用
所以考虑有 3 个 URL,让我们这样称呼它
let URL1 = "https://www.something.com"
let URL2 = "https://www.something1.com"
let URL3 = "https://www.something2.com"
还有一个我们将在其中存储值的数组
let promiseArray = []
现在,我想并行运行它 (Promise.all),但我无法弄清楚我们将如何做?因为 axios 本身就有一个 promise(或者至少我是这样使用它的)。
axios.get(URL).then((response) => {
}).catch((error) => {
})
问题:谁能告诉我我们如何使用 promise.all 和 axios 发送多个请求
【问题讨论】:
-
stackoverflow.com/questions/37149466/… 似乎与您的问题相似
标签: javascript promise axios