簡體   English   中英

Axios 已棄用並發請求?

[英]Axios deprecated concurrent requests?

目前 axios 自述文件說這個無用的格式化部分:

並發(已棄用)

請使用 Promise.all 替換以下函數。

處理並發請求的輔助函數。

axios.all(可迭代) axios.spread(回調)

那么是.all 和.spread 已棄用,還是使用 Promise.all 代替其他方法已棄用? 並發本身是否已棄用? 並發請求處理的推薦方法是什么?

As it says, they have deprecated their own axios.all(iterable) and axios.spread(callback) functions, instead recommending you use JS's new in-built Promise.all(iterable) function, which does almost the same thing: takes an可迭代的承諾作為輸入,並返回單個 Promise 解析為輸入承諾結果的數組。

README中的並發示例如下:

function getUserAccount() {
  return axios.get('/user/12345');
}

function getUserPermissions() {
  return axios.get('/user/12345/permissions');
}

Promise.all([getUserAccount(), getUserPermissions()])
  .then(function (results) {
    const acct = results[0];
    const perm = results[1];
  });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM