# Inconsistent data while fetching user post

**URL:** https://forum.social.plus/t/inconsistent-data-while-fetching-user-post/934
**Category:** JS SDK
**Created:** [September 25, 2023, 12:10pm UTC](https://forum.social.plus/t/inconsistent-data-while-fetching-user-post/934 "2023-09-25T12:10:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)
#### Post date: [September 25, 2023, 12:10pm UTC](https://forum.social.plus/t/inconsistent-data-while-fetching-user-post/934/1 "2023-09-25T12:10:41Z")

</div>

Hey,  
I am trying to fetch the user post using the below code.

```auto
PostRepository.queryPosts({
         targetType: "user",
        targetId: process.env.REACT_APP_AMITY_USER_ID,
        sortBy: "lastCreated",
        includeDeletedPosts: false,
        includeChildrenPosts: false,
        matchingOnlyParentPost: true,
        limit: 15,
})

```

The above code is working fine, I am getting all the data (500+ posts) active present in DB and the pagination also working as expected.

But when I change the params `includeDeletedPosts` to `true` then I am getting only 16 posts (active and deleted) of the user out of 500+. Pagination also not working for the above filter.

Please let me know If I am doing anything wrong here.

---

<div class="post-metadata">

### Author: ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)
#### Post date: [September 25, 2023, 2:31pm UTC](https://forum.social.plus/t/inconsistent-data-while-fetching-user-post/934/2 "2023-09-25T14:31:58Z")

</div>

Hi @Ashish thanks for reaching out, we will look into this.

---

<div class="post-metadata">

### Author: ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)
#### Post date: [September 27, 2023, 8:28am UTC](https://forum.social.plus/t/inconsistent-data-while-fetching-user-post/934/3 "2023-09-27T08:28:41Z")

</div>

Hello, we are unable to reproduce this problem on our side. Could you please review the sample code provided below and comparing it to your current code:

```auto
let userPostCollection;
  function queryUserfeed() {
    const liveCollection = PostRepository.queryPosts({
      targetType: 'user',
      targetId: 'John',
      sortBy: 'lastCreated',
      limit: 15,
      includeDeletedPosts: true,
      includeChildrenPosts: false,
      matchingOnlyParentPost: true,
    });

    userPostCollection = liveCollection
    liveCollection.on('dataUpdated', models => {
      console.log('user posts:', models);
    });
  }
  function queryUserfeedNext() {
    if (userPostCollection && userPostCollection.loadingStatus === "loaded" && userPostCollection.hasMore) {
      console.log('userPostCollection: ', userPostCollection);
      userPostCollection.nextPage();
    }

  }

```

---

<div class="post-metadata">

### Author: ![Ashish](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@Ashish](https://forum.social.plus/u/Ashish)
#### Post date: [October 4, 2023, 11:51am UTC](https://forum.social.plus/t/inconsistent-data-while-fetching-user-post/934/4 "2023-10-04T11:51:49Z")

</div>

Hey,  
This code looks similar, don’t know why I am facing this issue. I am changing only one key `includeDeletedPosts` rest everything is the same.

Could you please explain what the below parameters do?

```auto
     includeChildrenPosts: false,
     matchingOnlyParentPost: true,

```

---

<div class="post-metadata">

### Author: ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)
#### Post date: [October 5, 2023, 9:08am UTC](https://forum.social.plus/t/inconsistent-data-while-fetching-user-post/934/5 "2023-10-05T09:08:08Z")

</div>

- **includeChildrenPosts:** In this context, “ChildrenPosts” refer to elements such as images, videos, polls, and livestreams within the post.

- **matchingOnlyParentPost:** When set to `true`, it will filter only parent posts.

API for reference: [Amity API](https://api-docs.amity.co/#/Post%20v4/get_api_v4_posts)

 ![Screenshot 2566-10-05 at 09.51.04](https://europe1.discourse-cdn.com/flex013/uploads/amity/original/1X/9af0a9e1eaf382f9233c4e3bbf3e81395362b0dc.png)
