Wait page to pop before continue executing code

Hello. I’m iterating over a JSON that contains some rules to build my page. The loop is something like this:

  flux.forEach(element => {

My issue here is that I need to wait for this page to execute its action before call the next, this loop makes a stack. How can I make sort of a promise to wait the page to execute its duty before continue the loop?

Thank you all!