How to validate queries?

#1

Hello everyone!
I am finishing my app but im stuck in one thing, i need to implement a validation that allow me to know when the register is found and vice-versa. this is my function for consulting a register in my database.

Findproduct(){
try{
var referenceresultado= this.resultadoref.orderByChild(‘referencia’).equalTo(this.resultado);
referenceresultado.on(‘value’, itemSnapshot => {
this.products = [];
itemSnapshot.forEach( itemSnap => {
this.products.push(itemSnap.val());
return false;
});

});
}catch(Error){}

}

If the app find a register it have to show me a message saying “You got the product” or in other case “You dont got the product”

I build this alert

 let alert = this.alertCtrl.create({
title: ' You got the product',
buttons: ['OK'],

});
alert.present();

Please help me :slight_smile: