I’m trying to access the prop of a state that was set via payload, but it always remains undefined
export class UserStateModel { user!: User | null; currentRoles!: Roles[] | null;
And how i’m trying to set the state:
@Action(SetUser) setUser(ctx: StateContext<UserStateModel>, { payload }: SetUser) { ctx.patchState({ user: payload, currentRoles: payload.roles, }); }
My entities:
`export class User {
id!: string;
name!:string;
email!: string;
company!: Company;
token!: string;
roles!: Roles[];
}
export class Roles {
id!: string;
roleReference!: string;
createdAt!: Date;
updatedAt!: Date;
deletedAt!: Date;
}`
The server response object is correct, but the only property I can’t access is Roles
I’m trying to undertand why i ‘can’t access the prop from payload in the store (management state)
Luiz Paulo Pinto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.