![](/img/trans.png)
[英]ETIMEDOUT when making large(10k) post requests using axios.all nodejs
[英]Using axios.all with an instance for POST requests
我目前正在構建一個需要提交多個POST請求的應用。 我想使用axios.all
來實現這一點,因為在繼續之前,我可以驗證每個請求是否成功。
該應用程序使用axios實例,該實例聲明為client
。 但是,我遇到兩個問題:
client
無權訪問.all
迭代方法 client.post
請求添加到數組會立即執行它們 這是我正在使用的代碼的示例:
import axios from 'axios'
const client = axios.create({
baseURL: process.env.API_URL
})
let requests = []
for (let section of {{ some data }}) {
requests.push(client.post('response_endpoint', section.responses))
}
client.all(requests)
有什么方法可以使這項工作奏效,還是需要重新考慮我的方法?
嘗試使用Promise.all()
代替axios.all()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.