I try send http-request. I use angular 2 and rxjs library. I need send a request with a period of 5 seconds.
At first i import operator and use it follow:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
// import { interval } from 'rxjs/observable/interval';
import 'rxjs/add/observable/interval';
@Injectable()
export class TasksService {
  constructor(private http: HttpClient) { };
  getUserTasks(userId): Observable<any> {
    return this.http.interval(5000).get('http://127.0.0.1:8000/app_tasks/user_tasks?user_id=' + userId);
  };
}
Secondly i subscribe in component:
ngOnInit() {
  let userId = 1;
  this.getUserTasks(userId);
}
private getUserTasks(userId): void {  
  this.tasksService.getUserTasks(userId).subscribe(
    data => {   
      this.userTasks = JSON.parse(data);                 
      console.log('userTasks', this.userTasks);
    }
  )
};
But consoe display follow error message:
ERROR in src/app/services/tasks.service.ts(16,21): error TS2339: Property 'interval' does not exist on type 'HttpClient'.
 
     
     
    