https://cypress.io logo
EDIT: Solved Just want to ask if this is possible...
# best-practices
b
EDIT: Solved Just want to ask if this is possible:
Copy code
function jsonReader(filePath, cb) {
    fs.readFile(filePath, 'utf-8', (err, fileData) => {
        if (err) {
            return cb && cb(err);
        }

        try {
            const parsedObject = JSON.parse(fileData);
            return cb && cb(null, parsedObject);
        } catch (err) {
            return cb && cb(err);
        }
    });
}
I am trying to update a json file whenever this script is run. But unfortunately I always get a
fs.readFile is not a function
error. Have I missed anything here? Applogies if the code entry is too lengthy.