Include the tags in a Content API request

Is there any way to include the tags without using both include and fields?

This works:
await api.posts.browse({fields: "title,html,featured,feature_image,id,slug", include: "tags"})

This does not work:
await temp1.api.posts.browse({fields: "title,html,featured,feature_image,id,slug,tags"})
(Gives Error: Could not understand request.)

Hey! You shouldn’t have to use the fields option, this should work:

await api.posts
      .browse({
        include: "tags"
      })
      .catch(err => {
        console.error(err);
      });

Yeah, it does, but I do not need all the unnecessary data. It is about 30% faster when I use only the fields I need.

Fair enough. I don’t think you can use tags in the fields option because it’s not actually a field, it’s an array of objects. Here’s what worked for me:

api.posts.browse({
  fields: "title,html,featured,feature_image,id,slug",
  include: "tags"
})

Oh, okay! I was mostly worried due to Useful for optimising queries, but does not play well with include..
Thanks!

1 Like