Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 搜索查询4 RESTAPI_Node.js_Angular_Typescript_Express - Fatal编程技术网

Node.js 搜索查询4 RESTAPI

Node.js 搜索查询4 RESTAPI,node.js,angular,typescript,express,Node.js,Angular,Typescript,Express,我遵循有效的教程: 我需要为我的应用程序更改一些信息,但不起作用。 以下代码: 组成部分: export class SearchComponent implements OnInit { articlePosts; results: Object; searchTerm$ = new Subject<string>(); constructor( private searchService: SearchService, private auth

我遵循有效的教程: 我需要为我的应用程序更改一些信息,但不起作用。 以下代码: 组成部分:

 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());

  }
}
<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));
  });