A
A
adizh2022-01-30 13:20:25
Vue.js
adizh, 2022-01-30 13:20:25

How to load next page data?

Need to make a pokemon app using pokeapi. And when you click on the Next button, you need to display the data of the next page.
61f6662f6c4d6548459890.png
the next page data needs to be obtained (data.next). How can this be done in Vuex? Do I need to create a separate action and a new axios request?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2022-01-31
@adizh

No "next" page is needed here. Store the number of the current page and the number of elements on the page, calculate the value of the offset parameter based on this data. When you need the next - do +1 to the current one.

Do I need to create a separate action...

No need, action should be one, get the page number as a parameter. For example .

A
Alexander, 2022-01-30
@Aleksandr-JS-Developer

Do I need to create a separate action and a new axios request?

And what do you think?
When you click on the next button, you pass a link in the $route parameters (or rather, the page number in the query and generate a link based on the page number), in the view component on the created hook, hang up an action with axios.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question