this is my service
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class LocalStorageService {
constructor() {}
setItem<T>(key: string, object: T) {
localStorage.setItem(key, JSON.stringify(object));
}
getItem(key: string) {
return JSON.parse(localStorage.getItem(key)!);
}
removeItem(key: string) {
localStorage.removeItem(key);
}
isExist(key: string) {
if (JSON.parse(localStorage.getItem(key)!)) {
return true;
} else {
return false;
}
}
}
This is my codes
GetUserById() {
this.authService.GetUserById(localStorage.getItem('Id')).subscribe(
(response) => {
this.user = response.data;
this.editProfileForm.setValue({
Id:this.user.Id,
FirstName: this.user.FirstName,
LastName: this.user.LastName,
Email: this.user.Email,
password: '',
});
},
(responseError) => {
this.toastrService.error(responseError.error);
}
);
}
so Argument of type 'string' is not assignable to parameter of type 'number'. this is the error so how can i get nubmer what should i change my service or what should i do i trying things but i cant
this line is error >>>>>>>>> this.authService.GetUserById(localStorage.getItem('Id')).subscribe <<<<<
CodePudding user response:
Number(localStorage)
Number(this.authService)
// 'Id',JSON.stringify(this.Id)
this.authService.GetUserById(Number(localStorage.getItem("userId"))).subscribe(
(response) => {
this.user = response.data;
console.log(response.data)
no one answer but i find it