Hey!
So I’m building a small webapp with Strapi as a Backend. I’ve introduced a very basic like-system. Users can like articles. At one point I retrieve a list of likes the user has made. I populate this list with the posts that the likes refer to.
const requestUrl = `/post-likes?populate[users_permissions_user][fields][0]=id&populate[post][fields][0]=title&filters[users_permissions_user][id][$eq]=${userId}&sort=createdAt:desc`
Naturally the editors will unpublish or delete articles over time. In this case the API currently returns null for the posts, causing a widget on my frontend to break.
So I would like to filter out posts that are null.
I’ve tried adding a filter to the end of my query &[filters][$notNull]=true
But that caused an error 500.
const requestUrl =
/post-likes?populate[users_permissions_user][fields][0]=id&populate[post][fields][0]=title&filters[users_permissions_user][id][$eq]=${userId}&sort=createdAt:desc&[filters][$notNull]=true`
Does anyone have an idea how I could approach this? I am also open to a pure backend solution, like a policy or sth
Would love to get some feedback from you guys!
Cheers from Bavaria,
Max
This topic has been created from a Discord post (1239933587093065788) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord