I encountered the following TypeScript errors in app.component.ts:
Issue: Argument of type '(events: Event[]) => void' is not assignable to parameter of type '(value: Event[]) => void'.
Description: Types of parameters 'events' and 'value' are incompatible.
Solution: Type 'Event[]' is not assignable to type 'import("/home/src/app/models/event.interface").Event[]'.
Error: Type 'Event' is missing properties like _id, name, date from type 'Event'.
Reviewing my code:
event.interface.ts
export interface Event{
_id: string;
name: string;
date: Date;
}
app.service.ts
getEvents(): Observable<Event[]> {
return this.http.get<Event[]>('www.example.com/your-events')
}
app.component.ts
ngOnInit() {
this.appService.getEvents().subscribe(
(events: Event[]) => {
this.promotersEvents = events;
}
)
}
I'm seeking advice on what might be wrong with my code. Thank you!