【发布时间】:2020-03-14 05:46:26
【问题描述】:
我正在尝试遍历 API 结果的所有页面,该结果将下一页作为结果中的 URL 返回:
const api_url= 'https://wger.de/api/v2/exercise/?format=json&page=29';
async function getExercises(){
const response = await fetch(api_url);
const data = await response.json();
data.results.forEach( item => console.log(item.name))
}
getExercises();
你会怎么做呢?
【问题讨论】:
标签: javascript json api loops