this post was submitted on 30 Jun 2023
1 points (100.0% liked)

Lemmy App Development

693 readers
2 users here now

A place for Lemmy builders to chat about building apps, clients, tools and bots for the Lemmy platform.

On-Topic:

Off-Topic:

founded 1 year ago
MODERATORS
 

Sometimes an API request returns {"comments":[]} and {"posts":[]} respectively, for a post and community, where posts and comments show up on the web frontend. Is that happening to any of you too? How do I handle it?

Edit: did some more testing, it's most definitely a federation issue. If I query the instance that the post was made on for the comments, everything works fine. If I query my home instance, the result comes back empty.

Edit 2: As always, just after publicly showcasing my lack of programming abilities, I discover it's been me the entire time. Make sure to await promises and to fetch posts from the correct instance, guys.

top 2 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 year ago
[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

Edit: did some more testing, it’s most definitely a federation issue. If I query the instance that the post was made on for the comments, everything works fine.

Oh, I ran into that. There is a post on [email protected] even.

You need to set the type_=All on fetching comments for a community that isn't originated on your local server. You can just use that parameter when fetching comments from any post.