12 lines
358 B
JavaScript
12 lines
358 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 this
|
|
// Read a file that does not exist. This will throw an error.
|
|
const wrong = fs.readFileSync(path.join(__dirname, 'wrong.json'), 'utf8');
|
|
console.log(wrong);
|