angular2-jwt:AuthHttp 导致错误 'Expected 0 type arguments, but got 1.'
angular2-jwt: AuthHttp causes an error 'Expected 0 type arguments, but got 1.'
当我在下面的代码中使用来自 angular2-jwt 的 AuthHttp 时,我看到错误:
"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);
}
如果我使用 http: HttpClient,代码运行良好。
要使用 AuthHttp 运行 在此代码中更改什么?
你确定你用对了吗?
我希望它看起来像这样:
this.http.get(url)
.map( (res) => res.json())
.subscribe(
data => this.thing = data,
err => console.log(error),
() => console.log('Request Complete')
);
我找到了解决方案:
public getData(): Observable<User[]>{
const url = environment.apiUrl + `users`;
return this.authHttp
.get(url)
.map((res: Response) => <User[]>res.json());
}
当我在下面的代码中使用来自 angular2-jwt 的 AuthHttp 时,我看到错误:
"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);
}
如果我使用 http: HttpClient,代码运行良好。
要使用 AuthHttp 运行 在此代码中更改什么?
你确定你用对了吗?
我希望它看起来像这样:
this.http.get(url)
.map( (res) => res.json())
.subscribe(
data => this.thing = data,
err => console.log(error),
() => console.log('Request Complete')
);
我找到了解决方案:
public getData(): Observable<User[]>{
const url = environment.apiUrl + `users`;
return this.authHttp
.get(url)
.map((res: Response) => <User[]>res.json());
}