Reputation: 443
I have a json file mappings.json
in my assets/data
directory. I've created a service with the intention of making a HTTP call from the service so that the file can be used within the app.
However the HTTP call I'm making always seems to return a 404.
constructor(private http: HttpClient) {
this.http.get<PropMappings>("src/assets/data/mappings.json").subscribe(res => {
this._propMappings = res;
console.log(this._propMappings);
});
}
I've tried the following URLs:
src/assets/data/mappings.json
assets/data/mappings.json
projectName/src/assets/data/mappings.json
What do I need to do here? This link just says I need the second URL, but that doesn't work: https://www.angularjswiki.com/angular/how-to-read-local-json-files-in-angular/
Upvotes: 0
Views: 646