15 lines
405 B
JavaScript
15 lines
405 B
JavaScript
// read the file and print the content
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const data = fs.readFileSync(path.join(__dirname, 'data.json'), 'utf8');
|
|
console.log(data);
|
|
|
|
// Fix the file and print the content
|
|
try {
|
|
const wrong = fs.readFileSync(path.join(__dirname, 'wrong.json'), 'utf8');
|
|
console.log(wrong);
|
|
} catch (err) {
|
|
console.error('Error reading file. Does it exist?');
|
|
}
|