Though it is not possible to access a variable inside try block outside its scope, is there any other way to set it up so that it is could be accessible globally? I am using this is node.js.
var edata = 0;
if (file !== null)
try {
new ExifImage({ image: myfile }, function myexif(error, exifData) {
if (error) console.log('Error: ' + error.message);
else {
edata = exifData;
// console.log(edata); data is printed here as wanted.
}
});
} catch (error) {
console.log('Error: ' + error.message);
}
console.log(edata); //need to access data here (outside of the scope)