I keep encountering an error message that says 'observable is not generic' while importing files. I am working on implementing CRUD operations in Angular 7, where I have created two components for adding and listing employees. The functions for creating and retrieving the employee list are written in "policy.service.ts", and this is where I am facing the issue.
This is a snippet from my package.json file:
{
"name": "crudop",
"version": "0.0.0",
...
}
policy.service.ts
import {
Injectable
} from '@angular/core';
...
import {
Observable
} from 'rxjs/Observable';
@Injectable({
providedIn: 'root'
})
export class PolicyService {
constructor(private http: HttpClient) {}
private url = 'api/employees';
getEmployees(): Observable < IEmployee[] > {
return this.http.get < IEmployee[] > (this.url);
}
createUseremployee(user: IEmployee): Observable < IEmployee > {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type':'application/json'
})
};
return this.http.post < IEmployee > (this.url, user, httpOptions);
}
}
The problem lies with the getEmployee
and createUseremployee
functions where the type 'observable is not generic'. I am contemplating whether to reinstall everything or if there is another solution that could resolve this issue.