I am Trying to display the content of a CSV File in Angular.
To Test if it can read the .csv it I wrote following Method:
public readCsv(){
this.httpClient.get('/testdata/csv/test.csv', {responseType: 'text'})
.subscribe(
data => {
console.log(data);
},
error => {
console.log(error);
}
);
}
However if I run the Application I get following error:
Http failure response for http://localhost:4200/testdata/csv/test.csv: 404 Not Found
The .csv is in this folder:
src > app > testdata > csv > test.csv
The api.service.ts in which I the Method is written here: src > app > api.service.ts
I am running the Method in the testdata.component.ts which lays here:
src > api > testdata > testdata.component.ts
with following code:
ngOnInit() {
this.apiService.readCsv();
}
What am I doing wrong? Why do I get a 404 Not Found Error? How could I correctly read the file and even display it?