In my code I consulted 2 services and put their results (objects) within an array called deferreds
.
These objects have a property called results
, which is another array
.
I need to get the first of these objects, and give a push()
of all results
of the other objects in it, because I'm going to display it in a popup
.
My problem is that this only works when I put a breakpoint
in the browser and I go from line to line. When I run normal in the browser, it gives an error saying def.results[0]
is undefined, but when I go slowly debugando
it does have a value, and everything runs normal.
Any tips?
var deferred = null;
deferreds.forEach(function (def) {
if (deferred == null) {
deferred = def;
} else {
def.results[0].forEach(function (defer) {
deferred.results[0].push(defer);
});
}
});
this.mapa.infoWindow.setFeatures([deferred]);
this.mapa.infoWindow.show(evt.mapPoint);