我有一個 NIH API,一次只能調用 50 頁。下面的代碼適用于 50 個項目的第一頁。loadNIH() { let offset = 0; axios({ method: "GET", url: "https://api.federalreporter.nih.gov/v1/projects/search?query=orgName:Medical University of South Carolina$fy:2016$&offset=" + offset +"&limit=50" }) .then(res => { this.NIHData = res.data.items; }) .catch(function(error) { console.log(error); }); },我需要循環所有頁面,直到獲得所有數據。每次偏移需要增加接收到的頁面數(請求 50)9 個頁面。我需要它將數據添加到 this.NIHData 的數組中。我有一個工作,所以我需要一些幫助來創建循環。
使用 Vue 和 AXIOS 從 API 循環構建數組
慕絲7291255
2021-08-20 17:32:48