How can call the same request for let say 5 times on page load and with infinite scroll it calls the same request again for 5 times? On each time the currentCount should increase by 1.
How can i achieve that?
this is my .ts file
currentCount = 0
getUserList() {
this.showLoader();
this.search.page = this.currentCount;
this.authService.getData(this.search, "search")
.then((result) => {
let yourString = typeof result == 'object' && result["_body"] ? result["_body"] : [];
let res = yourString.substring(1, yourString.length - 1);
this.response = JSON.parse(res);
this.userData = JSON.parse(res).details.data
}, (err) => {
console.log(err);
});
}
doInfinite(): Promise<any> {
this.currentCount = this.currentCount + 1;
return new Promise((resolve) => {
setTimeout(() => {
this.authService.getData(this.search, "search")
.then((result) => {
let yourString = typeof result == 'object' && result["_body"] ? result["_body"] : [];
let res = yourString.substring(1, yourString.length - 1);
this.response = JSON.parse(res);
const newData = this.response.details.data
console.log(newData);
for (let i = 0; i < newData.length; i++) {
this.userData.push(newData[i]);
}
}, (err) => {
console.log(err);
});
console.log('Async operation has ended');
resolve();
}, 500);
})
}