Looping over a Dataset

Hi

I am trying to loop over a dataset using a loop that would work with an iterator. The loop gets stuck because because the next() does not seem to increment the iterator … Am I missing something ?

Thanks.

// data is a dataset
while(data.hasNext()) {
data.next().then( res => { // the next() does not increment the iterator …

			// and the loop gets stuck here forever ... 
				
	}); 
	
		
	}

Here is a working loop’https://www.wix.com/code/home/forum/questions-answers/looping-through-dataset

I saw this, but I have to say that the code is not elegant: iterators allow avoiding for loops and make code much more elegant. I will have to resort to regular for like in it was done in this post. Thanks for the reply !

Hi,
I would use the Wix Data API , get the relevant information and iterate the records using forEach loop.

Best,
Tal

thanks, yes, this is what I did