Whenever I try to fetch data from the server, these errors keep popping up.
This code was written by someone else and I would like to improve upon it.
Could anyone suggest the best approach to handle this situation? Are there any coding patterns that should be followed in order to optimize the code for performance?
ERROR Error: InvalidPipeArgument: '' for pipe 'AsyncPipe'
@Injectable()
export class EmployeePortalService implements Resolve<any>{
areas: any[]
organs: any[]
units: any[]
selectedArea: any
selectedOrgan: any
constructor(
private http: HttpClient
) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
return new Promise<void>((resolve, reject) => {
Promise.all([this.loadAll()]).then((response: any) => {
resolve(response)
}, reject)
})
}
loadAll(): Promise<any>{
return new Promise((resolve, reject) => {
this.http.get("/api/getWorkAreas").subscribe((response: any) => {
this.areas = response
resolve(response)
}, reject)
})
}
}