I call the funciontmp function and it returns an array with information correctly, but when I call function funciontmp2, I return a tmp array again, an empty array of tmp2 and finally an array with tmp2 information. The last two array shows them 20 seconds later. It is possible that multiple calls of the objects are generated.
<button type="button" (click)="funciontmp()" ion-button >tmp</button>
<button type="button" (click)="funciontmp2()" ion-button >tmp2</button>
funciontmp(){
this.apiCtrl.getObjectByFk('imagen', '-LDnDs0UHIHb0JH7e24T', 'id').subscribe(data_imagen => {
console.log(data_imagen)
});
}
funciontmp2(){
this.apiCtrl.getObjectByFk('imagen', '-LF0hQpaxxF9GZZkshhD', 'id').subscribe(data_imagen => {
console.log(data_imagen)
});
}
getObjectByFk(model,id,fk){
let query ={
query: {
orderByChild : fk,
equalTo : id
}
};
return this.afDB.list(model+'/',query);
}