I am new to angular so I was following a tutorial and have the following code:
//Fetching users
getUsers(size: number =10): Observable<any>{
return this.http.get<any>(`${this.apiUrl}/?results=${size}`);
}
The above code is for a component called user.services, this functiontries getting a api response, to use this method on another component I have the following:
export class UsersComponent implements OnInit {
constructor(private userService: UserService) { }
ngOnInit(): void {
this.userService.getUsers(10).subscribe(
(results: any) => {
console.log(results);
}
);
}
}
Since I am injecting the userService on the constructor of the users.components.ts file I don't understand why I get the error saying Property 'getUsers' does not exist on type 'UserService'
I am able to see that VSCODE also sees the function definition
what could be the issue for this?
