import { Component } from '@angular/core'; import { Http, Headers } from '@angular/http'; import { FormsModule } from '@angular/forms'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { searchquery = ''; tweetsdata; data; screenname; constructor(private http: Http) {} makecall() { // tslint:disable-next-line:prefer-const let headers = new Headers(); headers.append('Content-Type', 'application/x-www-form-urlencoded'); this.http.post('http://localhost:3000/authorize', { headers: headers }).subscribe((res) => { console.log(res); }); } searchcall(id) { // tslint:disable-next-line:prefer-const let headers = new Headers(); const searchterm = 'query=' + this.searchquery + '&id=' + id ; headers.append('Content-Type', 'application/x-www-form-urlencoded'); this.http.post('http://localhost:3000/search', searchterm, { headers: headers }).subscribe((res) => { console.log(res.json().data); this.tweetsdata = res.json().data.statuses; this.data = res.json().data; }); } }