Ever since I updated my npm and all modules today, I've run into a new problem. Everything was working perfectly fine before the update.
The error message reads: "the type 'any [] | undefined' cannot be assigned to the type 'any []'"
Here is the code snippet:
this.myservice.myfunction().toPromise().then((data) => {
this.variable = data;
}).catch((error) => {
console.log("Promise rejected with " + JSON.stringify(error));
});
In the service file, the function looks like this:
myfunction(): Observable<any[]> {
return this.http.post<any[]>(`${this.baseUrl}/GetDataFromBackend`, {}).pipe(
map((res) => res),
catchError(this.handleError);
);
}
Does anyone have any insights on why this error started popping up after the update? How can I go about fixing it? I seem to encounter this issue across multiple components and backend connections...