Using the HTTP Client, I\'m to retrieve a JSON file which resides the assets directory within my Angular 6 App which was generated using the CLI. While I know t
Several notes...
After running the server, just do a simple thing: copy/paste your resource URL into the browser, like this:
If you see the JSON then everything is fine, it means the problem is with how it is requesting from the Angular app. To understand the issue open Network section (or console) in your browser, most probably the issue is that how you are requesting the file.
For example, this: this.http.get('http://localhost:4200/assets/us-all-all.geo.json');
will most probably be converted to:
http://localhost:4200/http://localhost:4200/assets/us-all-all.geo.json'.
See my point?
Solution is simply to call the resource without
http://localshost:4200,
like:
this.http.get('assets/us-all-all.geo.json');