I'm trying to get code since frontend after of ask information to a apiRest endpoint, my problem is that I need to require an element into the information that I'm decoding of JSW token, but for some reason I can't asign the element, I think is something wrong whit my async/promise.
My error is being marked on tokeninfo.userId inside ngOninit and it says the next:
Property 'UserId' does not exist on type 'Promise'
TeamDataModel: TeamDataModel = new TeamDataModel();
btnSubmit: HTMLButtonElement;
UserModelData: UserModelData = new UserModelData();
CompanyModelData: CompanyModelData = new CompanyModelData();
ngOnInit(): void {
this.InitForms();
// Consiguiendo el ID del URL
this._route.paramMap.subscribe((params => {
if (params.has('CompanyId')) {
this.CompanyModelData.CurrentCompanyId = params.get('CompanyId');
}
}));
const info: any = localStorage.getItem('_$');
const token = atob(info);
const tokeninfo = this.DecodedToken(token);
this.UserModelData.UserId = tokeninfo.UserId;
this.SelectCompanysByUserId(this.UserModelData.UserId);
}
async DecodedToken(token) {
try {
const res: ResponseModel = await this._login.DecodedToken(token).toPromise();
if (res.Code == ECodeResponse.Ok){
return token = res.Data;
}
}catch{}
}
if you need more information please ask for them
question from:
https://stackoverflow.com/questions/65934232/trying-to-receive-a-service-for-make-reading-after 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…