> For the complete documentation index, see [llms.txt](https://developer.cscmobicorp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.cscmobicorp.com/firebase/tich-hop-firestore/4.-nhan-du-lieu.md).

# 4. Nhận dữ liệu

* Sử dụng **GetSnapshotAsync()**: để nhận dữ liệu

Code mẫu:

```csharp
void Start()
{   
    LoadFireStore("Main", firebaseUser.UserId);
}
private void LoadFireStore(string collectionName, string documentId)
{
    FirebaseFirestore.DefaultInstance.Collection(collectionName).Document(documentId).GetSnapshotAsync().ContinueWithOnMainThread(task =>
    {
        if (task.IsFaulted)
        {

            Debug.LogError("Can't connect to database: " + task.Exception);
        }
        else if (task.IsCompleted)
        {
            DocumentSnapshot snapshot = task.Result;
            if (snapshot.Exists)
            {
                try
                {
                    var data = snapshot.GetValue<string>("data");
                    Debug.Log($"Data: {data}");
                }
                catch (System.Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
            else
            {
                Debug.LogError("Khong co du lieu");
            }
        }
    });
}
```

Kết quả:

<figure><img src="https://2104621774-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgeyYu23aXsOKQRAzehmS%2Fuploads%2FZuYrus52lbukhW6goMhu%2Fimage.png?alt=media&amp;token=f4023bc7-320d-4a0b-8fad-cd01e55605ad" alt=""><figcaption></figcaption></figure>
