title: Getting request body of mock service worker and react testing library
body: <p>So i am writing tests for one of my react projects and i just decided to use mock service worker to mock my api calls and i am trying to mock a login endpoint.So i am trying to simulate a login error where i return an error message when the input does not match a particular email. Given the code below;</p>
  <pre><code>const server = setupServer(
    rest.post(&quot;https://testlogin.com/api/v1/login&quot;, (req, res, ctx) =&gt; {
      // the issue is getting the email from the request body something like the code just below
      if (req.body[&quot;email&quot;] != &quot;test@example.com&quot;) {
        ctx.status(401);
        return res(
          ctx.json({
            success: false
          })
        );
      }
    })
  );
  </code></pre>
  <p>How can i do that? Is there a better way to do that?</p>