Error when run a http.get multiples times – Cannot read property ‘get’ of undefined – Angular

My projet is used to receive data from an API in real time. The data is on API and I collect variables by using a .CSV file on the web server of a S7-1500 Siemens.

So, to receive data in real time, I want to make a setInterval in my service to run this function more than one time.

At the first loop, the API call works, but the second time it loops, I have this error:

Type Error: Cannot read 'get' of undefined 
at line.service.ts 
at getData(line.service.ts:25).

The second time, I have a problem with http.get, but I don’t find how to resolve that after lot of searches.

The code :

import {BehaviorSubject, combineLatest, Subject, Subscription} from 'rxjs';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Injectable, OnDestroy} from '@angular/core';

export class LineService{
  constructor(private http: HttpClient) {
    setInterval(this.getData, 5000);

  lineSubject = new BehaviorSubject<RcvData[]>([]);

  getData(): void {
    console.log('One Loop');
    const lists: string[] = [
    combineLatest( => this.http.get(list, {responseType: 'text'})))
      .subscribe(listResults => {

        const parsedListResults = => {
          const csvToRowArray = data.split('n');
          const lastRow = csvToRowArray[csvToRowArray.length - 2];
          const row = lastRow.split(',');
          return new RcvData(
            parseInt(row[0], 10),
            row[1], row[2],parseInt(row[3], 10), row[4], row[5], row[6], row[7],
            parseInt(row[8], 10),
            parseInt(row[9], 10),
            parseInt(row[10], 10),
            parseInt(row[11], 10),
            parseInt(row[17], 10))

class RcvData{
  seqNo: number;
  date: string;
  utcTime: string;
  id: number;
  name: string;
  refCharge: string;
  refDecharge: string;
  quantiteEnCours: string;
  quantiteHoraireReel: number;
  quantiteHoraireTheorique: number;
  quantitePosteReel: number;
  quantitePosteTheorique: number;
  trpHeureReel: number;
  trpPosteReel: number;
  trpObjectif: number;
  consoAir: number;
  consoElec: number;
  status: number;

    seqNo: number,
    date: string,
    utcTime: string,
    id: number,
    name: string,
    refCharge: string,
    refDecharge: string,
    quantiteEnCours: string,
    quantiteHoraireReel: number,
    quantiteHoraireTheorique: number,
    quantitePosteReel: number,
    quantitePosteTheorique: number,
    trpHeureReel: number,
    trpPosteReel: number,
    trpObjectif: number,
    consoAir: number,
    consoElec: number,
    status: number)
    this.seqNo = seqNo; = date.replace(/ /g, '').replace(/"/g, '');
    this.utcTime = utcTime.replace(/ /g, '').replace(/"/g, ''); = id; = name.replace(/"/g, '');
    this.refCharge = refCharge.replace(/ /g, '').replace(/"/g, '');
    this.refDecharge = refDecharge.replace(/ /g, '').replace(/"/g, '');
    this.quantiteEnCours = quantiteEnCours.replace(/ /g, '').replace(/"/g, '');
    this.quantiteHoraireReel = quantiteHoraireReel;
    this.quantiteHoraireTheorique = quantiteHoraireTheorique;
    this.quantitePosteReel = quantitePosteReel;
    this.quantitePosteTheorique = quantitePosteTheorique;
    this.trpHeureReel = trpHeureReel;
    this.trpPosteReel = trpPosteReel;
    this.trpObjectif = trpObjectif;
    this.consoAir = consoAir;
    this.consoElec = consoElec;
    this.status = status;

Every answer is welcome, thanks a lot !

Source: Angular Questions