I have generator
function* pendingPage() {
let value = 1;
while (true)
yield getPage(value++);
}
I have getPage()
function
async function getPage(value) {
const page = await service.getValidations(value);
(page.data.customers.length === 0) ? service.isCustomersFinished = false : console.log(page.data.customers);
}
I have while infinite loop with the following syntax:
let generator = pendingPage()
while(true){
generator.next();
}
And I want to use generator.next()
function inside it. But the generator does not work.
I tried with the for
loop, and it works fine.
So, what is the problem with it and how to use generator.next()
inside infinite while loop?