I am doing a login system and im querying the entry by the user to verify if it exists on firestore, if it finds his his input, then i log it onto the console. Until this part all is well, when he inputs something that exists, it brings his data. However, when he inputs something that does NOT exists it inputs an empty array "[]" which means that there's no such thing. My problem is very simple, i can't find the proper logic to console log when his input does not exist and thats pretty much it.
Here's my code
pageLogin() {
var auxint = 0;
this.dataAux
let auxString = '[';
var query = firebase.firestore().collection("armazenaTest")
query.where('Documento.login', '==', this.User.login).get().then(res => {
res.forEach(item => {
if (item.exists) {
auxint++;
auxString += '{"id":"' + item.id + '","armazenaTest":' + JSON.stringify(item.data()) + '}';
if(item.get('Documento.login') == this.User.login){
console.log('Document found!: ', item.data())
}
}
if (res.size != auxint)
auxString += ', ';
})
auxString += ']';
this.dataJSON = JSON.parse(auxString);
console.log(this.dataJSON);
}).catch(err => {
console.log('An error occured ' + err);
});
}