Function not getting called

Here, the findUser function works fine but the getData function is not getting invoked and run. I would like any advice in pointing out what I am wrong.

Hi Kiri,
It definitely looks like getData is called.
One idea for what could be going on:
Both functions call asynchronous code, so the two async requests are performed immediately after each other.
When getData is called, the ‘’ has most likely not been set yet.

So perhaps getData should be called from the inside of the callback in findUser?
In that way the two calls will be performed one after the other.

Could this perhaps be what is going on?

I understood what you are saying, Sir.
But when you say that getData must be called from the inside of the callback in findUser, what exactly does that mean?

Hi again Kirti (and sorry I got your name wrong before).
By ‘callback’ I am referring to lines 41 to 51 in the screenshot above. These lines define a function that is ‘called back’ by the Firestore ‘getDocuments()’ once it has fetched the documents.
So if you insert a line after line 50 and call ‘self.getData()’ from here, then it is only called after the has received it’s value.

Terms of Service

Privacy Policy

Cookie Policy