I have a function that gets the data from a saved file into the myJson variable. How can I check that the file exists without it affecting the below methods? Also, the file is in another folder that the one of the src of the project. It is in the backend dedicated folder. How can I access it from Angular and also to check if the file exists?
import myJson from 'src/assets/myFile.json' ;
readFile() {
this.savedData=myJson;
console.log("this is data from file "+this.savedData);
return myJson;
}
constructor (){
this.savedData= this.readFile();
}