Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readFile(filePath, 'utf8', function (err, data) {
if (err) {
reject(new errors.io.FileLoadError(filePath));
return;
}
try {
var contents = JSON.parse(data);
} catch (error) {
reject(new errors.Error('JSON.parse', error));
return;
}
resolve(contents);
});
});