我有我的组成部分:
export class CatalogoComponent implements OnInit {
items: Catalogue[];
constructor(private srvCat: CatalogueService) { }
ngOnInit() {
this.srvCat.getItems()
.subscribe(response => this.items = response);
}
}
这是我的服务:
export class CatalogueService {
constructor(private http: HttpClient) { }
getItems(page?: number): Observable<Catalogue[]> {
if (!page)
page = 1;
return this.http.get<Catalogue[]>('http://localhost:8888/catalogues' + '?page=' + page);
}
}
如何通过服务从组件中的http客户端响应中获取正文和标头。