json - how can I get all the date from a multiple pages from a json api?
问题描述
There are 61 pages in this json file but with this call I only get the first page of it? How can I get all of them, please? Is there a loop or another way to use axios?
<template>
<div id="app">
<thead>
</thead>
<tbody>
{{items}}
</tbody>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
items:[]
}
},
created() {
axios.get(`https://zbeta2.mykuwaitnet.net/backend/en/api/v2/media-center/press-release/?page=2&page_size=12&type=5`)
.then(response => {
this.items = response
})
}
}
</script>
解决方案
尝试不使用?page=2&page_size=12&type=5
:
axios.get(`https://zbeta2.mykuwaitnet.net/backend/en/api/v2/media-center/press-release/`)
或者您可以设置每页要接收的文章数量(在您的情况下为 61 页,每页 12 篇文章):
axios.get(`https://zbeta2.mykuwaitnet.net/backend/en/api/v2/media-center/press-release/?page=1&page_size=732&type=5`)
推荐阅读
- batch-file - 如何记录任务列表的计数
- vertica - 如何使重复的vertica中现有的表列值唯一?
- android - 我的 videoview 说“无法播放视频”,但 webview 可以播放吗?
- asp.net-mvc - 等待的呼叫在单元测试中丢失上下文
- javascript - 用户交互超级事件
- javascript - js如何破坏函数的默认值?
- python - 制作成对的文件和列以在循环中使用?
- selenium - 无法通过 selenium 获取 ul 标签下的所有 li 项
- arrays - 解析数组时如何简化 if..else 语句
- glsl - 如何使用6个sampler2D实现textureCube