Creating my own api

Hello, I’m new in strapi I try to create my own api. Im trying to get when i’m logged in that the users that have at least one of the same interest as other user will see in my postman. All the interest are in a multi select. Now I got a empty object and the error: error: **Cannot read properties of undefined (reading ‘interests’) **, I gave the same interest in the backend strapi to the users, but it don’t show in postman. here some screenshots: Is there someone that can help me please!

This topic has been created from a Discord post (1242024368461320253) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Hi. you are not going to get this with multi select custom field

if i remember correctly it’s based on json field

witch is impossible to filter on unless you use some postgres magic

what you have to do:

  1. is to remove the custom field
  2. add a collection called Interests
  3. add a relation hasMany interests to your user

then you would be able to query using:

const query = {
  filters: {
    $and: [
      {
        id: { $not: userId },
      },
      {
        interests: {
          slug: {
            $eq: interestSlug,
          },
        },
      },
    ],
  },
};

/api/users?filters[$and][0][id][$not]=userId&filters[$and][1][interests][slug][$eq]=interestSlug