I am currently facing an issue with a dummy service I created to fetch dummy data. When calling this service from a component ts file, I encountered the following error.
After searching through some similar posts, I still haven't been able to resolve my specific problem.
Error message:
Error: src/app/roaster-load/file-load-init/file-load-init.component.ts:60:19 - error TS2339: Property 'data' does not exist on type 'any[]'.
file-load-init.component.ts:
`
import { NgbModal, ModalCloseReasons, NgbModalOptions } from '@ng-bootstrap/ng-bootstrap';
import { BaseComponent } from '../../common/scripts/baseComponent';
import { WINDOW } from '../../common/scripts/window.service';
import { Component, OnInit} from '@angular/core';
import { HttpClientModule, HttpClient, HttpHandler } from '@angular/common/http';
import { UploadService } from '../UploadService/upload.service';
import { InvalidSOEIDModel } from '../Uploadmodel/uploadmodel';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-file-load-init',
templateUrl: './file-load-init.component.html',
styleUrls: ['./file-load-init.component.css']
})
export class FileLoadInitComponent implements OnInit {
InvalidSOEIDCount: any;
InvalidSOEIDModel:InvalidSOEIDModel[];
ngOnInit(): void {
}
constructor(private http: HttpClient,
private UploadService: UploadService,) {}
OnUpload(){
this.GetSOEIDVerifyData();
};
private GetSOEIDVerifyData(){
this.UploadService.UploadDataReturn()
.subscribe((res: any[]) => {
console.log(res);
if (res.data) {
this.InvalidSOEIDCount = res.data;
}
}
)}
}
upload.service.ts:
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { InvalidSOEIDModel } from '../Uploadmodel/uploadmodel'
import {of} from 'rxjs';
@Injectable()
export class UploadService {
UploadDataReturn(): Observable<InvalidSOEIDModel[]> {
return of([
{
SOEID: "AAAAA"
},
{
SOEID: "BBBBB"
}])
}
}