last day (14 days later) » 

6:29 PM
0
A: Angular2 HTTP Service cannot find file

Joel RichmanThe Angular CLI by default only delivers static content from the assets folder. You can change that in the .angular-cli.json file by adding a data folder (or other static content, file or directory) to the assets array: "apps": [ { "root": "src", "outDir": "dist", "assets"...

 
Where is the angular-cli.json file typically located?
 
In the root of your application. It starts with a period .angular-cli.json.
 
I edited the .angular-cli.json file and it still cannot find that file
 
Did you restart the server after editing the file? ng serve uses that file when it initializes the server. I should have mentioned that in my answer.
 
Yes, I completely restarted the server
 
6:29 PM
Remove the "./" in the url. url = "data.json"
 
Still cannot find the file
 
I modified my answer slightly. Your assets should include the "data" folder or "data/data.json" if you want to be specific about the file and your url should be "data/data.json". My apologies, I didn't look closely enough at the image of your file structure.
 
Ok so I adjusted according to your answer and it still cannot find the file. Is there something wrong with my EmailService class?
 
You should be able to hit the url directly and, depending on your browser, display or download the file. localhost:4200/data/data.json if that works, something is wrong with the EmailService.
Your data folder needs to be under the Src folder. Move it and that should fix it.
 
Something has to be wrong with EmailService because it still doesn't work
 
6:29 PM
Did you move the data folder under src. I'm pretty sure that is the final fix.
 
I moved the data folder inside of the source folder and it still couldn't find it
I'm thinking that within emai.service that this.url inside of getEmail(); is not coming though as the string I set as my url. THat's the only thing I can think of
So whenever the browser calls localhost:4200 what directory is it in right then
 

last day (14 days later) »