My code is something like this:
var trueOrFalse = true;
while(trueOrFalse){
fetch(\'some/address\').then(){
if(someCondition){
trueOrFals
while
loop is sync
where fetch
is async
in nature, so while
won't wait for fetch
async
operation to complete and going to next iteration immediately.
You can achieve this synchronously like following:
function syncWhile(trueOrFalse){
if(trueOrFalse) {
fetch('some/address').then(){
if(someCondition){
trueOrFalse = false;
}
syncWhile(trueOrFalse);
}
}
}
syncWhile(true);