I have the following Get request in server...
var imageFiles = [];
var dir = 'public/img/';
fs.readdir(dir, function(err, files){
if (err) return console.error(err);
files.forEach(function(file) {
file = dir + file;
imageFiles.push(file)
});
});
res.send(imageFiles);
res.end();
imageFiles always returns to angular as an empty array. If I console.log(imageFiles) before the response it is empty as well. However, if I console.log(files) they are all there. What am I doing wrong!?