天天看点

SAP Spartacus B2BUserService的一个问题

This issue is for discussion in this StackOverflow question: https://stackoverflow.com/questions/66458798/how-can-i-detect-current-users-user-group-in-spartacus

SAP Spartacus B2BUserService的一个问题
In order to test it, I add the following source code in AppModule’s constructor:

constructor(b2b: B2BUserService){
    const result = b2b.getUserGroups('ab3f7a08-690a-4616-b1fe-4f0847fcb79f', {
      pageSize: 100
    });
    result.subscribe((data) => console.log('Ethan: ' , data));
  }      
SAP Spartacus B2BUserService的一个问题

I expect the user group data is printed.

Unfortunately I meet with this error message:

ERROR TypeError: Cannot read property ‘b2bUser’ of undefined

SAP Spartacus B2BUserService的一个问题

callstack:

SAP Spartacus B2BUserService的一个问题

Do I need to call some other method to “initialize” the state before I access it?

继续阅读