I’m working on a controller file inside a plugin. I’m fetching the following content from api::league.league
. I would like the const league
to have the type of the content that’s being fetch, but instead its type end up being AnyEntity | null
. How can I cast it to the correct content type, or is there something I’m missing?.
File src\plugins\green-gaming\server\controllers\leagues.ts
const league = (await strapi.entityService.findOne('api::league.league', leagueID, {
fields: ["name"],
populate: {
teamsV2: {
populate: {
team: {
fields: ["id", "name", "tag"],
},
replaces: {
fields: ["id"],
}
}
},
}
}))
This topic has been created from a Discord post (1274017893499011103) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord