Reputation: 111
I'm trying to access input data that's stored inside of a .json
file but for some reason my path isn't recognised:
This method runs when data is requested:
getData() {
console.log('this is working');
this.http.get('src/app/inputs/inputs.json')
.subscribe(
(data: any) => {
console.log('this is working');
console.log(data.text());
}
);
}
}
This is my folder structure:
I am able to add the data whenever a separate button is clicked, just retrieving it is where I get stuck.
Upvotes: 0
Views: 293
Reputation: 1726
I think you have to add your inputs folder in the assets section of angular.json eg
"assets": [
"src/assets",
"src/inputs",
"src/favicon.ico"
]
then access your data through
this.http.get('inputs/inputs.json')
Upvotes: 3