import { Component } from '@angular/core';

import { BooksService } from './books.service';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    books: string[] = [];

    constructor(private service: BooksService) { }

    search(title: string) {
        this.books = [];
        this.service.getBooks(title).subscribe(
            success => this.books = success,
            error => console.error(error)
        );
    }
}

import { Component } from '@angular/core';
import { Http } from '@angular/http';

import { BooksService } from './books.service';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    books: string[] = [];

    constructor(private http: Http, private service: BooksService) { }

    search(title: string) {
        this.books = [];
        this.service.getBooks(title).subscribe(
            books => this.books = books,
            error => console.error(error)
        );
    }
}

--- 
+++ 
@@ -1,5 +1,4 @@
 import { Component } from '@angular/core';
-import { Http } from '@angular/http';
 
 import { BooksService } from './books.service';
 
@@ -10,12 +9,12 @@
 export class AppComponent {
     books: string[] = [];
 
-    constructor(private http: Http, private service: BooksService) { }
+    constructor(private service: BooksService) { }
 
     search(title: string) {
         this.books = [];
         this.service.getBooks(title).subscribe(
-            books => this.books = books,
+            success => this.books = success,
             error => console.error(error)
         );
     }
Remove unused code in angular-rest-service books service
