could you tell me why the value of the global variables below are lost?
public maximo: number[];
public minimo: number[];
public media: number[];
they are in a typescript file.
I fill them inside the typescript method below. the first console.log prints correctly the values. the second is empty. I didn't understand why the second is empty. Could you tell me why, please?
buscaTempos(quantidade: number) {
this.maximo = [];
this.minimo = [];
this.media = [];
this.recursos = [];
this.tempoRespostaRecursoService.getTempoRepostaRecursos(quantidade).then((res) => {
if(res.httpRequest!=null) {
this.tempo = JSON.stringify(res);
var jsonData = JSON.parse(this.tempo);
for (var j=0; j < jsonData.httpRequest.length; j++) {
var counter = jsonData.httpRequest[j];
this.maximo.push(counter.itemDTO.maximum);
this.minimo.push(counter.itemDTO.minimum);
this.media.push(counter.itemDTO.average);
this.recursos.push(counter.rest);
}
console.log(this.maximo);
}
});
console.log(this.maximo);
}