I am trying to delete a json file from assets folder permanently via my component.
I tried using HttpClient. There is no error, but the file doesn't get deleted.
constructor(http: HttpClient){}
remov() {
this.http.delete('assets/myJson.json');
}
CodePudding user response:
Angular runs in your browser, you cannot directly delete files using angular or javascript from your browser. The files are hosted on your server.
What you can do it to implement an API on your server i.E. using Node.js & Express.js and then call that API and delete any file using fs
var fs = require('fs');
fs.unlinkSync(filePath);