src / app / shared / services / users.service.ts(1,21)中的ERROR:错误TS2305: 模块'“ C:/ xampp / htdocs / home-money / node_module s / @ angular / common / http“'没有导出的成员'Response'。
无法解决问题
import {HttpClient, Response} from '@angular/common/http';
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {User} from '../models/user.model';
@Injectable()
export class UsersService {
constructor(private http: HttpClient) {
}
getUserByEmail(email: string): Observable<User> {
return this.http.get(`http://localhost:3000/users?email=${email}`)
.map((response: Response) => response)
.map((user: User[]) => user[0] ? user[0] : undefined);
}
}
答案 0 :(得分:0)
此问题在 import {HttpClient, Response} from '@angular/common/http';
中
@angular/common/http
中没有作为响应的导出成员。它应该是 HttpResponse
。
import {HttpClient, HttpResponse} from '@angular/common/http';
getUserByEmail(email: string): Observable<User> {
return this.http.get(`http://localhost:3000/users?email=${email}`)
.map((response: HttpResponse) => response)
.map((user: User[]) => user[0] ? user[0] : undefined);
}
答案 1 :(得分:0)
您的输入错误是应该的
import {HttpClient, HttpResponse} from '@angular/common/http';
而且也不需要
.map((response: HttpResponse) => response)
我没看到您做任何修改响应数据的操作