Inside my Angular app i i want to liste all files names inside assets folder.
So that i want to use this npm library : list-files-in-dir
https://www.npmjs.com/package/list-files-in-dir
Sso i ve this service inside my angular app :
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {listFiles} from 'list-files-in-dir';
@Injectable()
export class ConfigService {
files: any;
constructor(private http: HttpClient) { }
getFilesFromFolder(){
listFiles('assets/')
.then(files => {
// do what ever you want with the file paths
this.files = files
console.log(this.files)
}
}
}
but when calling it i get this error :
ERROR Error: Uncaught (in promise): Error: Error: ENOENT: No such file or directory., '/assets' Error
i ve done a stackblitz snippet for this :
https://stackblitz.com/edit/angular-read-jsonfile-data
Suggestions ?