PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 31, 2022

[FIXED] how to declare pageSize in axios get api for pagination vue 3 while it has the data

 July 31, 2022     axios, pagination, vue.js, vuejs3     No comments   

Issue

I'm using Tailwind Pagination for my vue app. I'm currently getting all the data from axios get, and it also gets page: 1 and pageSize: 200 from api. enter image description here but they've told me that I have to send the numbers myself and I'm stuck in the middle of it... I'm getting data like:

in Employee page: async getUser() { await this.$store.dispatch("axiosGet", {url: 'identity/api/employees'}).then(response => { if (response.status === 'error') return this.userList = response.data.data.data this.page = response.data.data.page this.pageSize = response.data.data.pageSize this.totalCount = response.data.data.totalCount console.log(response.data.data) }) },

and then, in Tailwind component passed data through:

in Table component:

then, inside the VPagination component it's what's happening:

<VueTailwindPagination
:current="page"
  :total="totalCount"
  :per-page="pageSize"
  @page-changed="pageChange($event)">
  </VueTailwindPagination>

then:

props: {
userList: {type: Object},
page: {type: Number},
pageSize: {type: Number},
totalCount: {type: Number}
},

methods:

pageChange(pageNumber) {
  this.currentPage= pageNumber
},

so, there's only one page and no pagination is possible.

enter image description here

the Swagger is like this: enter image description here

Can anyone help me with the problem?


Solution

You can get your data like this:

async getUser() {
 await this.$store.dispatch("axiosGet",
 {url: `identity/api/employees?page=${1}&pageSize=${10}`})
 .then(response => {})
},

but you need to replace the constant value with your local variables...



Answered By - Ali Sharafi
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing