var fs = require('fs');
var path = require('path');
var bodyParser = require('body-parser');
var express = require('express');
var app = express();

var POEMS_FILE = path.join(__dirname, 'poems.json');

app.use('/', express.static(path.join(__dirname, 'client/public')));
app.use(bodyParser.urlencoded({extended: true}));

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.get('/api/poem', function (req, res) {
  fs.readFile(POEMS_FILE, function (err, data) {
    if (err) {
      console.error(err);
      process.exit(1);
    }
    res.json(JSON.parse(data));
  });
});

app.post('/api/poem', function (req, res) {
  if (req.body.poems && Array.isArray(req.body.poems)) {
    let poems = req.body.poems;
    fs.writeFile(POEMS_FILE, JSON.stringify(poems, null, 4), function (err) {
      if (err) {
        console.error(err);
        process.exit(1);
      }
      res.json(poems);
    });
  } else {
    fs.readFile(POEMS_FILE, function (err, data) {
      if (err) {
        console.error(err);
        process.exit(1);
      }
      let poems = JSON.parse(data);
      let newPoem = {
        id: Date.now(),
        title: req.body.title,
        author: req.body.author,
        collection: req.body.collection,
        text: req.body.text
      };
      poems.push(newPoem);
      fs.writeFile(POEMS_FILE, JSON.stringify(poems, null, 4), function (err) {
        if (err) {
          console.error(err);
          process.exit(1);
        }
        res.json(poems);
      });
    });
  }
});

app.listen(3000, function () {
  console.log('Server started and listening on port 3000!');
});

@@ -400,33 +400,24 @@
 '/api/poem',
- function
  (req, res) 
@@ -411,24 +411,27 @@
 , (req, res)
+ =%3E
  %7B%0A  fs.read
@@ -442,33 +442,24 @@
 (POEMS_FILE,
- function
  (err, data)
@@ -454,24 +454,27 @@
  (err, data)
+ =%3E
  %7B%0A    if (e
@@ -766,39 +766,33 @@
 s, null, 4),
- function
  (err)
+ =%3E
  %7B%0A      if 
@@ -929,25 +929,16 @@
 MS_FILE,
- function
  (err, d
@@ -941,16 +941,19 @@
 r, data)
+ =%3E
  %7B%0A     
@@ -1342,23 +1342,17 @@
  4),
- function
  (err)
+ =%3E
  %7B%0A 

Use arrow function for callbacks