-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Bug Description
I was trying to fetch all users from the Strapi CMS using the StrapiClient. The user collection type is allready in the CMS when you create a fresh install. I needed to show a list of users of a specific role on the frontend of my website. The return type of the find() method is of type DocumentResponseCollection or DocumentResponse if I'm trying to fetch a single type.
Steps to Reproduce
- When you have a blanco Strapi project.
- And try to fetch all the users with the following code:
let client = strapi({
baseURL: process.env.STRAPI_URL + '/api',
auth: process.env.STRAPI_TOKEN,
});
const response = await this.client.collection('users').find()
- When I try to access properties on
response.data, I got an exception that data is not defined. For instance when trying to get the username.
When I log the users to the console I can see that the JSON data is as follows:
Expected Behavior
For now fixed the error by casting the type to any, I would expect that the users collection type has a separate data container. A possible way to fix this would to create a sepperate method on the Strapi Client that is only responsible for fetching the users. The main thing that I noticed is that the users are directly on the response as an array and not wrapped in an object under the data property.
Version
1.4.0
Operating System
Windows
Runtime Environment
Node.js
Logs
Media
No response
Confirmation Checklist
- I have checked the existing issues
- I agree to follow this project's Code of Conduct
- I would like to work on this issue