How can I execute a service synchronously?
I have this code in a button click event:
precode
for (var i=0;i<table.length;i++){
localStorage.setItem('syncContactObj', table);
READ_myService.execute({});
}
/code/pre
In the request part of the myService, I have a javascript that uses localStorage.getItem('syncContactObj') to construct a filter.
But while the myService is executing with the first iteration of the for-loop, I suspect that the for-loop already continues and sets the next localStorage Item and initiates the next myService execute. But I use the localStorage Item in the myService success event, so when the 1st service is still executing, the localStorage item is already replaced with a new value of the 2nd for-loop iteration.
Which makes the code in the success event of the myService erronous, because it uses the localStorage item.
How can I make sure that the 1st service call is completed before the for loop continues with the next iteration?