import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
/*
Generated class for the PokedexProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class AppService {
constructor(public http: HttpClient) {
}
getBooks()
{
return this.http.get('http://booksapi.co/api/v2/book/2');
}
}
title: any = 'List of books are represted in the bookstore';
books: any = [];
constructor(private service: AppService){
}
ngOnInit(){
this.getBookDetails();
}
getBookDetails() {
this.service.getBooks().subscribe(books => {
this.books = books.json();
console.log(this.books);
});
}