Reputation: 99
I'm trying to make a "related articles" for a "blog-article" single based off the relation "blog-categories", but I can't seem to get the relations to appear in the api call. What's the API url with the correct parameters to get relations with Strapi?
To populate all of the articles in descending order by date with images, I'm doing:
const res =
await fetch (
https://localhost:3000/api/blog-articles?populate=*&sort[0]=publishDate%3Adesc
)
Edit: Fetch result Edit 2: Schema
Upvotes: 1
Views: 1664
Reputation: 4506
I think you can achieve this by passing the related field name in the populate
http query string.
GET http://localhost:3000/api/blog-articles?populate=blog_categories&sort[0]=publishedAt%3Adesc
const resp = await fetch('http://localhost:3000/api/blog-articles?populate=blog_categories&sort[0]=publishedAt%3Adesc');
const data = await resp.json();
console.log(data);
Upvotes: 0