0

I have 2 typescript/javascript async functions. And I have to call them Sequentially. I tried it many ways... but still no luck... Please check the below example.

for(let i=0; i<3; i++){

    console.log("i -> ", i);

    func1().then(()=>{
        
        for(let j=0; j<3; j++){

            console.log("j -> ", j);

            func2().then(()=>{
              
               console.log("******") 
                
            });
        }

    });
    
}

func1() and func2() are typescript/javascript async functions... Is it possible to get the below result from those typescript/javascript functions? Can anyone help me to solve this issue?

i -> 0
j -> 0
******
j -> 1
******
j -> 2
******
i -> 1
j -> 0
******
j -> 1
******
j -> 2
******
i -> 2
j -> 0
******
j -> 1
******
j -> 2
******

Thanks

Dilanka Rathnayake
  • 652
  • 2
  • 11
  • 31

0 Answers0