Piero Bosio
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
KaKi87@jlai.lu to Lemmy Support@lemmy.ml · 2 months ago

Why the API says a post doesn't have comments when the HTML page shows comments ?

message-square
message-square
7
link
fedilink
9
message-square

Why the API says a post doesn't have comments when the HTML page shows comments ?

KaKi87@jlai.lu to Lemmy Support@lemmy.ml · 2 months ago
message-square
7
link
fedilink

Hi,

This post has comments : https://jlai.lu/post/26123233

But when asking the API : https://jlai.lu/api/v3/comment/list?post_id=26123233&sort=Old

An empty array is returned.

Why ?

Thanks

alert-triangle
You must log in or register to comment.
  • Arthur Besse@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    2 months ago

    Looking at the network tab while loading a thread, I see you need to include type_=All.

    (lemmy-ui sends other parameters too but your example URL works for me with just tyoe_=All added.)

    • KaKi87@jlai.luOP
      link
      fedilink
      arrow-up
      2
      ·
      2 months ago

      Thanks.

      Now, why isn’t that required for an older post ?

      For example : https://lemmy.world/api/v3/comment/list?post_id=5&sort=Old

      • Dessalines@lemmy.mlM
        link
        fedilink
        arrow-up
        3
        ·
        2 months ago

        Read the API docs for what type means: https://join-lemmy.org/lemmy-js-client-docs/v0.19/classes/LemmyHttp.html#getComments

      • Arthur Besse@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 months ago

        i’m guessing it might have something to do with the fact that jlai.lu is configured to default to the Local view while lemmy.world defaults to All

        • KaKi87@jlai.luOP
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          Interesting, thanks !

  • NJSpradlin@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    8 days ago

    Is this why I don’t see a lot of comments on Voyager, and what’s the fix there?

    • KaKi87@jlai.luOP
      link
      fedilink
      arrow-up
      2
      ·
      7 days ago

      It might be, yes : https://github.com/aeharding/voyager/blob/main/src/routes/pages/shared/CommentsPage.tsx#L41

      As mentioned by @cypherpunks@lemmy.ml, the solution is to add type_=All in query parameters.

      From the Voyager app’s source code, it seems like the value is undefined by default.

      I think replacing this by All could fix the issue. But, I have no experience in that app’s dev stack, so I can’t be sure.

      Therefore, I’d suggest submitting a GitHub issue showing 2 screenshots : of the same post, one on Voyager, the other one on another app, where the former shows less comments than the latter. Indicate that replacing undefined with All might fix the issue.

      If the maintainer(s) reproduce and confirm, they’ll push the fix.

      If I was more confident, I’d directly make a PR, but I’m not.

Lemmy Support@lemmy.ml

lemmy_support@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !lemmy_support@lemmy.ml

Support / questions about Lemmy.

Matrix Space: #lemmy-space

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 5 users / day
  • 18 users / week
  • 182 users / month
  • 420 users / 6 months
  • 1 local subscriber
  • 5K subscribers
  • 152 Posts
  • 594 Comments
  • Modlog
  • mods:
  • Dessalines@lemmy.ml
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org