tslint is currently throwing the following error
Shadowed name: 'err'
Here is the code
fs.readdir(fileUrl, (err, files) => {
fs.readFile(path.join(fileUrl, files[0]), function (err, data) {
if (!err) {
res.send(data);
}
});
});
Anybody have a clue on what the best way would be to solve this and what the error even means?
You are using the same variable "err" in both outer and inner callbacks, which is prevented by tslint.
If you want to use the same variable then "no-shadowed-variable": false, otherwise do as below.
fs.readdir(fileUrl, (readDirError, files) => {
fs.readFile(path.join(fileUrl, files[0]), function (err, data) {
if (!err) {
res.send(data);
}
});
});