Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
How to get firestore queried data from angular service to component

I am new to Firestore and async functions. Below function is in angular service:

 async verifyCredentials(loginFormData:any)
  {
    const q = query(collection(db, "users"), where("mobile", "==", loginFormData["mobile"]), where("email", "==", loginFormData["email"]));
    const querySnapshot = await getDocs(q);
    //console.log("data is:", querySnapshot.docs[0].data());
    return querySnapshot.docs[0].data();
  }

I am calling above function to get data in a component:

 onSubmit() {
    
    this.submitted = true;
    if (this.loginForm.invalid) {
        return;
    }
    if(this.submitted)
    {
      console.log(this.userService.verifyCredentials(this.loginForm.value)); 
      //this.router.navigate(['/menu']);
    }
  
  }

Below is the console output:

Console

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It worked. I completely forget to use .then

onSubmit() { 
    this.submitted = true;
    if (this.loginForm.invalid) {
        return;
    }
    if(this.submitted)
    {
      this.userService.verifyCredentials(this.loginForm.value).then( data => 
      {
        console.log(data); 
      });
      //this.router.navigate(['/menu']);
    }
  }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!