Angular 4 - HTTP Service 404. JSON file Not Found
If you are using angular cli
you have to output your json file by setting that up in .angular-cli.json
like so:
"assets": [
"assets",
"src/employees.json"
],
But I would recommend to create a folder like data
inside your src
folder and place all your data .json
filed in to it. Then have your assets
config like so:
"assets": [
"assets",
"data"
],
This way cli will alway output the whole data
folder so you do not have to specify each .json
file separately
In case if you changing
.angular-cli.json
duringng serve
for your changes to take an effect you have to restartng serve
looks like you're trying to access a file in the "src" directory, which is never made statically available.
If you need to access that json file directly, you need to make sure it's stored in the proper directory in the webserver that it can serve directly (this is usually done by configuring the static/serve settings on the backend).
Just because a file exists in your project folder doesn't mean the webserver makes all of it available.