Is there a way to read all JSON files within a folder in my Meteor application?
This is the structure I currently have:
/server
-- /methods
-- -- file1.json
-- -- file2.json
I've attempted to read all JSON files using this code snippet:
var fs = Npm.require('fs');
var path = Npm.require('path');
var base = path.resolve('.');
try {
var files = fs.readdirSync(base + '/methods/*.json');
console.log(files);
} catch (e) {
console.dir(e)
}
However, I am encountering an error stating that the directory or file does not exist.
Am I missing something here? Or perhaps there is an alternative method to achieve this task? Any guidance would be appreciated.