Chapter 3: User-Facing Backend

Im unable to get the GetUSerAsync method to read from the database given a users email.

return await _usersCollection.Find(x=>x.Email==email);
Im I missing something or did I write it wrong?
Please help

Hi @Glenda_Mabasa.
You are almost there, but you need to pass the cancellation token along with the .FirstOrDefaultAsync method.
Hence your query would look something like:

return await _usersCollection.Find(x=>x.Email==email).FirstOrDefaultAsync(cancellationToken);

I hope it helps.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

2 Likes

Thanks a lot this really helped.it worked