I researched a lot about it and still could not find a solution.
When I run the code below, the loop proceeds before the API callback.
In the callback the variable this.userRoute.newRoute [i] .address is changed, so I need the loop to wait for the callback, to proceed from the new value that was entered in the array, which before the callback does not exist returns "undefined".
My question is if I can get the loop to wait for the callback to be executed to continue execution.
for(let i = 0; i < this.userRoute.route.length; i++){
service.getDistanceMatrix(
{
origins: [this.userRoute.newRoute[i].address],
destinations: composeDestination,
travelMode: 'DRIVING',
}, this.calcRouteDistanceResult.bind(this)
);
}