title: How to get the form data inside NestJS controller
body: <p>I am in the process of rewriting an existing PHP-based API into NestJS (while learning NestJS at the same time).</p>
  <p>Important bit is I cannot touch the frontend service, so I need to make sure that the new app can handle anything the frontend send to it, and respond with the same data structure the original api did.</p>
  <p>And here is where I am hitting a wall. Everything submitted by frontend app is in the form of <em>formdata</em>. The only example give in NestJS documentation pertains to getting the uploaded file, but not any additional data that may come with it. Google search was not much of a help so far.</p>
  <p>The best I found was this SO post <a href="https://stackoverflow.com/questions/63872093/accept-form-data-in-nest-js">Accept form-data in Nest.js</a> but I am still unable to get the submitted data.</p>
  <p>Submitted data:</p>
  <p><a href="https://i.stack.imgur.com/891TT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/891TT.png" alt="enter image description here" /></a></p>
  <pre><code>&gt; POST /public/login HTTP/1.1
  &gt; Host: localhost:3000
  &gt; Content-Type: multipart/form-data;
  &gt; Accept: */*
  &gt; Content-Length: 196
  
  | Content-Disposition: form-data; name=&quot;login&quot;
  | sampleuser
  | Content-Disposition: form-data; name=&quot;password&quot;
  | userpassword
  </code></pre>
  <p>content of my authentication.controller.ts:</p>
  <pre><code>import { Controller, Post, Body, Get, Param, Patch, Delete, Req, Header, UseInterceptors, } from &quot;@nestjs/common&quot;;
  
  @Controller()
  export class AuthenticationController {
  
      constructor() { }
  
      @Post('public/login')
      @UseInterceptors()
      login(@Body() body) {
          console.log(body);
      }
  }
  </code></pre>
  <p>the log result is simply <code>{}</code></p>
  <p>What am I missing/doing wrong here.  Do I need to install some extra npm package to make this work? It surely cannot be that difficult to obtain such common data. Can someone point me to a right direction or a working example.</p>
  <p>Thank you</p>