search查询angular度4restAPI

我遵循的教程工作: https : //alligator.io/angular/real-time-search-angular-rxjs/我需要改变我的应用程序的一些信息,但无法正常工作。 按照代码:组件:

export class SearchComponent implements OnInit { articlePosts; results: Object; searchTerm$ = new Subject<string>(); constructor( private searchService: SearchService, private authService: AuthService ) { this.searchService.search(this.searchTerm$) .subscribe(results => { this.articlePosts = results.articles; }); } } 

服务:

  export class SearchService { options; domain = this.authService.domain; queryUrl: string = '?search='; constructor( private authService: AuthService, private http: Http ) { } // Function to create headers, add token, to be used in HTTP requests createAuthenticationHeaders() { this.authService.loadToken(); // Get token so it can be attached to headers // Headers configuration options this.options = new RequestOptions({ headers: new Headers({ 'Content-Type': 'application/json', // Format set to JSON 'authorization': this.authService.authToken // Attach token }) }); } search(terms: Observable<string>) { return terms.debounceTime(400) .distinctUntilChanged() .switchMap(term => this.searchEntries(term)); } searchEntries(term) { return this.http.get(this.domain + 'articles/search + this.queryUrl + term').map(res => res.json()); } } 

HTML:

 <input (keyup)="searchTerm$.next($event.target.value)"> <ul *ngIf="results"> <li *ngFor="let article of articles | slice:0:9"> <a href="{{ result.latest }}" target="_blank"> {{ article.nome }} </a> </li> </ul> 

后端:

  router.get('/search', (req, res) => { var parsedURL = url.parse(req.url, true); res.send(JSON.stringify(parsedURL.query)); }); 

我需要我的数据库的查询数据,有人可以帮助我?