Pagination with Axios
See original GitHub issueWin 10 (1803) | Chrome 69 | Bootstrap vue 2.0.0-rc.11
When using pagination with axios response to calculate total number of pages, i have to double click the pager in order to see the next page contents:
<b-pagination
v-if="numbers.total > 24"
size="md"
v-model="currentPage"
:limit="6"
:total-rows="numbers.total"
:per-page="24"
@click.native="fetchNumbers()"
></b-pagination>
numbers total are comes from:
fetchNumbers () {
return axios.get(globalConfig.NUMBERS_URL, {
params: {
limit: 24,
offset: (this.currentPage - 1) * 24
}
})
.then((resp) => {
this.numbers = resp.data
// console.log(resp)
})
.catch((err) => {
console.log(err)
})
},
With lodash debounce, if i set a small delay, it works as intended, i suspect async there.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Update axios request for pagination - Stack Overflow
I have an axios GET request that displays an array of data, but only displays 15 items at a time. The API url...
Read more >Vue Pagination with Axios and API (Server Side ... - BezKoder
In this tutorial, I will show you how to make Pagination in a Vue.js Application with existing API (Server Side pagination) using Axios...
Read more >axios-hooks pagination - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >Retrieving Paginated API Data With Axios - xkln.net
I recently encountered an API which would only permit a limited number of objects to be returned. The objects in this case were...
Read more >ReactJS Pagination - React axios.get - YouTube
ReactJS Pagination - React axios.getSource Code : https://tutorial101.blogspot.com/2021/10/reactjs- pagination -react-axiosget.html.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a similar issue and fixed it by picking up the page via the method call from the change event, for example:
<b-pagination size="md" :total-rows="rowsCount" v-model="selectedPage" :limit="5" :per-page="50" @change="pageChanged"> </b-pagination>
Then the model value is passed to the pageChanged method, and can be picked up like so:
pageChanged(page) { // Do things with the page value }
The reason the other way doesn’t always work, is that getting the model via the normal way, doesn’t seem to update in time after the change (or click) event to have the new value.
Use @change instead of @click to fire off fetchNumbers() from user interaction after the model is updated.