Hello. I have a blog posts(articles) and categories. Categories has route /category/{slug} and shows related articles. But there is no limit and offset for the articles by some category. Can someone explain how to add such params to the /category/{slug}?limit=10&offset=0 to filter articles
can you share the solution, i have the same issue.
thanks
I found the answer in the Strapi source code itself. it’s not in the documentation.
We can use limit and start directly in the populate field.
const query = {
populate: {
articles: {
sort: "title:asc",
limit: 10,
start: 10,
},
},
};
const queryToString = qs.stringify(query, { encode: false });
const {
data: { data: categories },
} = await axiosApiInstance.get(
`${BACKEND_BASE_URL}categories/${id}?${queryToString}`
);
Try this method to solve.
http://127.0.0.1:1337/api/articles?filters[category]=1?pagination[page]=1&pagination[pageSize]=2
{
"data": [
{
"id": 2,
"attributes": {
"Name": "WPS Office",
"Description": "随时随地,办公更高效",
"createdAt": "2023-10-14T20:17:05.712Z",
"updatedAt": "2023-10-14T20:17:07.157Z",
"publishedAt": "2023-10-14T20:17:07.142Z"
}
},
{
"id": 10,
"attributes": {
"Name": "腾讯会议",
"Description": "腾讯会议,会开会",
"createdAt": "2023-10-14T21:21:22.914Z",
"updatedAt": "2023-10-14T21:22:21.133Z",
"publishedAt": "2023-10-14T21:22:21.122Z"
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 2,
"pageCount": 8,
"total": 15
}
}
}
articles?filters[category]=1?pagination[page]=1&pagination[pageSize]=2&populate=picture
Find articles in category and display article picture
any solutions for this issue