My table features a pagination-nav component:
<b-pagination-nav :link-gen="linkGen"
limit="5" :number-of-pages="10" use-router>
</b-pagination-nav>
To retrieve the table content, I am utilizing the getTrades
method that makes an HTTP request to a JSON API:
axios.get(`http://localhost:5000/trades/page/${page}`)
Each ${page} corresponds to a specific slice of data. The server-side code and requests are functioning properly. My goal now is to pass the page number from the clicked button to the getTrades
method. To achieve this, I invoke the getTrades
method within the linkGen
method.
linkGen(pageNum) {
console.log(pageNum);
this.getTrades(pageNum);
return pageNum === 1 ? '?' : `?page=${pageNum}`;
},
However, instead of receiving the correct page number, I am getting a random value from the list of page numbers. The linkGen
function logs out multiple random values from the list, but it still returns the correct page number.
EDIT: detailed code has been added
Here is the template section:
<!-- Template Code Goes Here -->
The script section includes:
<!-- Script Code Goes Here -->
An example of the server response looks like:
{
"status": "success",
"trades": [
{
"Asset": "GOLD-12.20",
"Date": "15.08.2020",
"Fee": 1.0,
"Operation": "Sell",
"Order": 61310215,
"Price": 1726.8,
"Qty": 1.0,
"Time": "21:34:17"
},
{
"Asset": "GOLD-12.20",
"Date": "15.08.2020",
"Fee": 1.0,
"Operation": "Buy",
"Order": 61310216,
"Price": 1726.8,
"Qty": 1.0,
"Time": "21:34:17"
}
]
}