V
V
VoRoN19992020-01-20 10:12:43
Vue.js
VoRoN1999, 2020-01-20 10:12:43

How to load data from Axios correctly?

Hello.
I am using this construct:

getImageList: function () {
 axios
     get('https://picsum.photos/v2/list?', {
       params: {
         page: this.page++,
         limit: this.pageSize,
       }
     })
     .then(response => (this.info.push = response.data));
}

<div v-for="infos in info" :key="infos.id">
   <img :src="infos.download_url" width="600"><br><br>
</div>

When scrolling the page, the data should load, but the old pictures are deleted and replaced with new ones.
It turns out that there were 5 of them, and 5 remain, only they change.
How to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2020-01-20
@VoRoN1999

This overwrites the past data with new ones
. So it is logical that you do not need to replace the array, but add new elements to it, i.e.
this.info.push.push(response.data)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question