I want to fetch the data from all the projects hosted by my GitLab instance. Now I know that GitLab displays 20 projects by default, so I need to set a bigger number of instances displayed per page:
https://gitlab-repo.com/api/v4/projects?per_page=100
It therefore leads to the corresponding axios code:
const url='https://gitlab-repo.com/api/v4/projects?per_page=100'
const vm = new Vue({
el: "#app",
data: {
results: [],
loading: true,
errored: false
},
mounted() {
axios
.get(url)
.then(response => (this.results = response.data))
.catch(error => {
console.log(error)
this.errored = true
})
.finally(() => this.loading = false)
}
})
The thing is, the maximum number of projects that GitLab can display per page is 100, and I have more projects than that.
I thought about putting a condition on the number of instances (projects) in the params
section of axios's get function but can't figure how to write that.
How can I indicate in my axios request that if the number of projects is bigger than 100, I want to load the data that's on the next page(s)?