# \[ts-sdk\] PostRepository.getPosts - subscribe to comments

**URL:** <https://forum.social.plus/t/ts-sdk-postrepository-getposts-subscribe-to-comments/741>\
**Category:** General\
**Created:** [May 16, 2023, 12:24pm UTC](https://forum.social.plus/t/ts-sdk-postrepository-getposts-subscribe-to-comments/741 "2023-05-16T12:24:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avo](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Avo](https://forum.social.plus/u/Avo)\
**Post date:** [May 16, 2023, 12:24pm UTC](https://forum.social.plus/t/ts-sdk-postrepository-getposts-subscribe-to-comments/741/1 "2023-05-16T12:24:43Z")

</div>

Hi Amity-Team,

I am in the process of migrating a React-native app (0.71) from the ts-sdk 0.0.1 to version 6.2.0.

And I have a problem with the liveCollection returned from PostRepository.

My Code looks like this:

```auto
	CommunityRepository.getCommunity(config.communityId, community => {
			const communityTopic = getCommunityTopic(
				community.data,
				SubscriptionLevels.POST_AND_COMMENT,
			);
			const topicUnsub = subscribeTopic(communityTopic, e => {
				e && console.error(e);
			});

			PostRepository.getPosts(
				{ targetId: config.communityId, targetType: 'community' },
				updatedPosts => {
					console.log(JSON.stringify(updatedPosts));
				},
			);
		});

```

So I am subscribing for post and comment updates and the console.log statement is written everytime I create a Post or add an reaction. So far so good.

In the Log I see:

```auto
Subscribed to topic 61..71/social/community/6...f9/post/#

```

What’s not working is comments. The SubscriptionLevels.POST\_AND\_COMMENT suggests that it should also work for those right?

When I use CommentRepository.getComments for a single Post it works but I have to create subscriptions for every single post in the community.

Is there something I am doing wrong here? Or whats the correct way to register for new Posts, Comments and Reactions is a community?

Thx

---

<div class="post-metadata">

**Author:** ![cijin](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@cijin](https://forum.social.plus/u/cijin)\
**Post date:** [May 17, 2023, 3:23am UTC](https://forum.social.plus/t/ts-sdk-postrepository-getposts-subscribe-to-comments/741/2 "2023-05-17T03:23:48Z")

</div>

Hey @Avo,

Your code looks correct, I’ll raise a ticket and look into it. Thank you for raising this issue and also for providing the all the necessary info. Much appreciated.

Thanks,  
Cijin

---

<div class="post-metadata">

**Author:** ![cijin](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@cijin](https://forum.social.plus/u/cijin)\
**Post date:** [May 17, 2023, 3:57am UTC](https://forum.social.plus/t/ts-sdk-postrepository-getposts-subscribe-to-comments/741/3 "2023-05-17T03:57:26Z")

</div>

Hey @Avo ,

Update on this, I’ve checked that you do receive RTE events for both `comments` and `post`.

Just to clarify, you would need to call `CommentRepository.getComments` but subscribing to each post is not neccessary.

I’ll leave the ticket open though, till you confirm it’s working. Maybe I can update the docs for clarification.

Cijin

---

<div class="post-metadata">

**Author:** ![Avo](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Avo](https://forum.social.plus/u/Avo)\
**Post date:** [May 17, 2023, 12:20pm UTC](https://forum.social.plus/t/ts-sdk-postrepository-getposts-subscribe-to-comments/741/4 "2023-05-17T12:20:17Z")

</div>

Thx for your feedback.

I believe the problem is caused by the fact that I was creating the comments witch client running on the old sdk version.  
It works fine when I create comments with the new code.  
So the subscription works correctly for my own comments.

I will retest this with two different users, but I think its solved for now.

---

<div class="post-metadata">

**Author:** ![cijin](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@cijin](https://forum.social.plus/u/cijin)\
**Post date:** [May 18, 2023, 11:26am UTC](https://forum.social.plus/t/ts-sdk-postrepository-getposts-subscribe-to-comments/741/5 "2023-05-18T11:26:27Z")

</div>

Hey @Avo,

Awesome, thank you so much for the update.  
Let me know if you have further question.

Cijin 🙂
