PostRepository.getPosts return video and image posts with dataType "text"

Hello @amitysupport.

I’m currently using PostRepository.getPosts to retrieve video, image, and text posts. According to the documentation, to fetch all types of posts, I should omit the ‘dataTypes’ parameter in the request parameters.

Here’s the code snippet in question:

      const params: Amity.PostLiveCollection = {
        targetId: userId,
        targetType: 'user',
        //dataTypes: ['image', 'video'],
        sortBy: 'lastCreated',
        limit: 8,

The problem I’m encountering is that when I remove the ‘dataTypes’ parameter, all the returned posts have their ‘dataType’ property set to ‘text’. However, when I uncomment ‘dataTypes’ in my request parameters, I receive posts with the correct ‘dataType’ values, such as ‘video’ and ‘image’.

It’s crucial for the ‘dataType’ property to be accurate because I use it to categorize user posts.

Thank you for your assistance.

Current TS-SDK: 6.4.5
I tested the latest version of the TS-SDK and observed the same behavior.

Hello, thank you for bringing this to our attention, we will pass to the team to further check :pray:

Many thanks.

I have another question: Why does the response change depending on the presence of the ‘dataTypes’ property?

When I omit that property, I receive parent posts. However, when I include it with ‘image’ and ‘video’ values, I receive all the children posts.

For me, it would be better to receive all children posts, including text posts, in order to avoid making other requests to obtain video or image files of posts.

Hello, and thank you for your patience. Our team has reviewed the situation, and we have confirmed that this behavior is intentional for our SDK. It is designed to return the parent post type, which is text, when specific data types are not specified.

Regarding your second question, this too is part of our design. We appreciate your feedback and will make sure to relay it to our team.

1 Like