0π
β
In general, it was necessary to create a condition to check that limit exceeds the number of rows of data:
const doSearch = (
offset: number,
limit: number,
order: string,
sort: string
) => {
table.isLoading = true
table.isReSearch = offset == undefined ? true : false
const i = limit
const url = 'https://jsonplaceholder.typicode.com/posts'
axios.get(url).then((response: any) => {
limit = offset + i
if (limit >= response.data.length) {
limit = response.data.length
}
if (sort === 'asc') {
table.rows = dataAsc(offset, limit, response)
} else {
table.rows = dataDesc(offset, limit, response)
}
// refresh table rows
table.totalRecordCount = response.data.length
table.sortable.order = order
table.sortable.sort = sort
})
}
Source:stackexchange.com