title: Why is req.body undefined in Express?
body: <p>I am creating a PUT method to update a given set of data however in my update function, req.body is undefined.</p>
  <p>controller.js</p>
  <pre><code>async function reviewExists(req, res, next) {
    const message = { error: `Review cannot be found.` };
    const { reviewId } = req.params;
    if (!reviewId) return next(message);
    let review = await ReviewsService.getReviewById(reviewId);
    if (!review) {
      return res.status(404).json(message);
    }
    res.locals.review = review;
    next();
  }
  
  async function update(req, res, next) {
    console.log(req.body);
    const knexInstance = req.app.get('db');
    const {
      review: { review_id: reviewId, ...review },
    } = res.locals;
  
    const updatedReview = { ...review, ...req.body.data };
  
    const newReview = await ReviewsService.updateReview(
      reviewId,
      updatedReview,
      knexInstance
    );
    res.json({ data: newReview });
  }
  </code></pre>
  <p>service.js</p>
  <pre><code>const getReviewById = (reviewId) =&gt;
    knex('reviews').select('*').where({ review_id: reviewId }).first();
  
  const updateReview = (reviewId, updatedReview) =&gt;
    knex('reviews')
      .select('*')
      .where({ review_id: reviewId })
      .update(updatedReview, '*');
  </code></pre>
  <p>How it should look:</p>
  <pre><code>&quot;data&quot;: {
      &quot;review_id&quot;: 1,
      &quot;content&quot;: &quot;New content...&quot;,
      &quot;score&quot;: 3,
      &quot;created_at&quot;: &quot;2021-02-23T20:48:13.315Z&quot;,
      &quot;updated_at&quot;: &quot;2021-02-23T20:48:13.315Z&quot;,
      &quot;critic_id&quot;: 1,
      &quot;movie_id&quot;: 1,
      &quot;critic&quot;: {
        &quot;critic_id&quot;: 1,
        &quot;preferred_name&quot;: &quot;Chana&quot;,
        &quot;surname&quot;: &quot;Gibson&quot;,
        &quot;organization_name&quot;: &quot;Film Frenzy&quot;,
        &quot;created_at&quot;: &quot;2021-02-23T20:48:13.308Z&quot;,
        &quot;updated_at&quot;: &quot;2021-02-23T20:48:13.308Z&quot;
      }
  </code></pre>
  <p>The first function where I check if a review exists work with my delete method. Am I missing something in one of these functions that would make req.body undefined?</p>