Utilizing my service, I fetch API data for the child component. Initially, it retrieves the Id and other user data, displaying it in the console.
ngOnInit(): void {
this.commonService.userSetChange.subscribe(
apiData => {
this.getUserSeminar(apiData);
this.user = apiData;
console.log(this.user)
});
}
Next, I save this data using a variable named user
.
user: any;
The following method is used to pass the user
variable:
addSeminar(): void {
console.log(this.user.id)
event.preventDefault();
const seminar = {
id: null,
user_id: this.user.id,
dates: null,
name: null,
certificate_number: null,
edit: true,
};
this.userSeminars.push(seminar);
const a = this.userSeminars.length - 1;
}
However, upon clicking the addSeminar button,
<button class="btn btn-primary btn-sm" (click)="addSeminar()">Add Seminar <i class="fa fa-plus"></i></button>
An error is encountered: api/users/seminar/null 500