Search code examples
angularangular2-jwtauthhttp

angular2-jwt: AuthHttp causes an error 'Expected 0 type arguments, but got 1.'


when I use AuthHttp from angular2-jwt in code below, I see error:

"Expected 0 type arguments, but got 1."

public getData(): Observable<User[]>{
const url = environment.apiUrl + "users";

return this.authHttp
  .get<User[]>(url)
  .map((res: User[]) => res);
  }

If I use http: HttpClient, code works well.

What to change in this code to run it with AuthHttp?


Solution

  • I found a solution:

       public getData(): Observable<User[]>{
        const url = environment.apiUrl + `users`;
    
        return this.authHttp
          .get(url)
          .map((res: Response) => <User[]>res.json());
      }