How to add user "role" when call : 'await fetchUser()' ?
Hello,
const { fetchUser } = useStrapiAuth()
const user2 = await fetchUser()
Question : How to add user "role" on the response FROM await fetchUser() ??
I would like use "populate" : but I don't understand how it works. Do you have an example ?
PS : i use nuxtjs 3.
Thanks.
Yeah, really interested in how to add populate=* to the user request. Cause I assume population of relations from /users/me has been fixed, but I can't figure out how to do it with the plugin
I also need this. I tried using the auth.populate params in nuxt config but not luck. Also seems that populating other relations do not work. I just get the default /me/ properties.
@titoff002 Hey, at least it works with useStrapiUser, you have to give permission to the role in strapi to find it's own role first. Then the nuxt.config.ts strapi config object add the auth: {populate: ['role']}} object.
Here is a solution:
- Modify your nuxt config :
strapi: {
auth: {
populate: ['role']
}
},
- Don't forget to enable find and findOne role permissions for authenticated users in the users permissions plugin.