Using Nuxt3 and the Strapi v4 Plugin to create a blog.
Using the findOne
function to retrieve ONE article.
However using the populate
parameter to also retrieve relational parameters such as images:
findOne<Article>('articles', { populate: "images"}, id)
returns a list of ALL articles. I want only my one article!
How do I get only the result for my given ID including the relations (images) when using the findOne
function with the populate
paramter?
Docs I consulted:
Your query syntax is wrong. findOne
takes id
as the second parameter and options
as the third parameter as below:
findOne(uid: string, id: ID, parameters: Params) ⇒ Entry
const entry = await strapi.entityService.findOne('api::article.article', 1, {
fields: ['title', 'description'],
populate: { category: true },
});
const entry = await findOne<Article>('articles', 1, {
fields: ['title', 'description'],
populate: { images: true },
});