i’m trying to deploy my web application with frontend: angular
but i can’t access my JSON file in assets folder
so this is the funstion to get data from JSON file
getLanguage()
{
let language=localStorage.getItem('language')
if (!language)
language = 'english'
return this.http.get('www/dist/assets/languages/'+language+'.json')
}
}
and this is the path of the file in my server :
i’m trying to access the file JSON in my server
but i can’t , i don’t if its’ an URL problem or something else ?
2
Answers
As per the comment on your question, this should work:
The folder is relative to your application folder (
src
folder at dev time).You also need to ensure that the assets folder is defined in the angular.json file.
Under
"architect"
and"build"
, ensure you have something that looks like this:try
return this.http.get('./assets/languages/'+language+'.json')
that is add
./
beforeassets/