Answers for "fs.access doesn't access callback"

0

fs.access doesn't access callback

const checkPermissions = file => {
  try {
    fs.accessSync(file, fs.constants.R_OK);
    console.log('can read/write');
    return true;
  } catch (err) {
    console.error('is not readable is readable________________');
    return false;
  }
};

if (checkPermissions('./some/location/file.pdf')) {
  console.log('I have permissions to the file');
} else {
  console.error('I do NOT have permissions to the file');
}
Posted by: Guest on December-07-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language