I tried to create a mobile web app, using wp-rest-api-v2 … but I get the problem when you want to do the pagination (infinite scroll) .Data always repeat!
page 1.ts
xport class Page1 {
datas:any
pagination: number = 1;
constructor(
public navCtrl: NavController, private postService: Post){
postService.getPosts(this.pagination).then(data => {
console.log(data);
this.datas = data;
});
}
infiniteScroll(ev){
this.pagination=+1;
this.postService.getPosts(this.pagination)
.then(data => {
for(let i of data){
this.datas.push(i);
}
ev.complete();
});
};
provider
getPosts(pagination){
return this.http.get('http://127.0.0.1:85/wordpress/wp-json/wp/v2/posts/?per_page=10&page='+pagination)
.toPromise() .then(data => data.json());
}
}
Pleasse Help Me