Node 09


In our working directory, we have an enigma.txt file with the following content:

The elephant is in the room.

In the same working directory, we have the following app.js file:

// app.js
const fs = require('fs');

const path = require('path');
const ENIGMA_FILE = path.join(__dirname, 'enigma.txt');

const promisedReadFile = (file) => {
  return new Promise((resolve, reject) => {
    fs.readFile(file, 'utf-8', (err, data) => {
      if (err) {
        reject('There was an error reading the file');
      }
      resolve(data);
    });
  });
};

const dataPromise = promisedReadFile(ENIGMA_FILE);

console.log('start');
console.log(dataPromise);
console.log('end');

What is displayed to the screen when we execute the app.js file?