title: Node.js - how to inspect request data?
body: <p>I have a Node.js route that sends back some text and logs the request:</p>
  
  <pre><code>app.post('/registerUser', function (req, res) {
    res.send('Hello World post!')
    console.log(req);
  })
  </code></pre>
  
  <p>Then I hit that route with curl, like so:</p>
  
  <p><code>curl --data "username==test&amp;foo==bar" http://localhost:3000/registerUser</code></p>
  
  <p>And that's what I'm getting out via node:</p>
  
  <pre><code>IncomingMessage {
    _readableState:
     ReadableState {
       objectMode: false,
       highWaterMark: 16384,
       buffer: BufferList { head: null, tail: null, length: 0 },
       length: 0,
       pipes: null,
       pipesCount: 0,
       flowing: null,
       ended: false,
       endEmitted: false,
       reading: false,
       sync: true,
       needReadable: false,
       emittedReadable: false,
       readableListening: false,
       resumeScheduled: false,
       defaultEncoding: 'utf8',
       ranOut: false,
       awaitDrain: 0,
       readingMore: true,
       decoder: null,
       encoding: null },
    readable: true,
    domain: null,
    _events: {},
    _eventsCount: 0,
    _maxListeners: undefined,
    socket:
     Socket {
       connecting: false,
       _hadError: false,
       _handle:
        TCP {
          bytesRead: 183,
          _externalStream: {},
          fd: 14,
          reading: true,
          owner: [Circular],
          onread: [Function: onread],
          onconnection: null,
          writeQueueSize: 0 },
       _parent: null,
       _host: null,
       _readableState:
        ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: [Object],
          length: 0,
          pipes: null,
          pipesCount: 0,
          flowing: true,
          ended: false,
          endEmitted: false,
          reading: true,
          sync: false,
          needReadable: true,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          defaultEncoding: 'utf8',
          ranOut: false,
          awaitDrain: 0,
          readingMore: false,
          decoder: null,
          encoding: null },
       readable: true,
       domain: null,
       _events:
        { end: [Object],
          finish: [Function: onSocketFinish],
          _socketEnd: [Function: onSocketEnd],
          drain: [Object],
          timeout: [Function],
          error: [Function: socketOnError],
          close: [Object],
          data: [Function: socketOnData],
          resume: [Function: onSocketResume],
          pause: [Function: onSocketPause] },
       _eventsCount: 10,
       _maxListeners: undefined,
       _writableState:
        WritableState {
          objectMode: false,
          highWaterMark: 16384,
          needDrain: false,
          ending: false,
          ended: false,
          finished: false,
          decodeStrings: false,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: false,
          bufferProcessing: false,
          onwrite: [Function],
          writecb: null,
          writelen: 0,
          bufferedRequest: null,
          lastBufferedRequest: null,
          pendingcb: 3,
          prefinished: false,
          errorEmitted: false,
          bufferedRequestCount: 0,
          corkedRequestsFree: [Object] },
       writable: true,
       allowHalfOpen: true,
       destroyed: false,
       _bytesDispatched: 222,
       _sockname: null,
       _pendingData: null,
       _pendingEncoding: '',
       server:
        Server {
          domain: null,
          _events: [Object],
          _eventsCount: 2,
          _maxListeners: undefined,
          _connections: 1,
          _handle: [Object],
          _usingSlaves: false,
          _slaves: [],
          _unref: false,
          allowHalfOpen: true,
          pauseOnConnect: false,
          httpAllowHalfOpen: false,
          timeout: 120000,
          _pendingResponseData: 0,
          _connectionKey: '6::::3000' },
       _server:
        Server {
          domain: null,
          _events: [Object],
          _eventsCount: 2,
          _maxListeners: undefined,
          _connections: 1,
          _handle: [Object],
          _usingSlaves: false,
          _slaves: [],
          _unref: false,
          allowHalfOpen: true,
          pauseOnConnect: false,
          httpAllowHalfOpen: false,
          timeout: 120000,
          _pendingResponseData: 0,
          _connectionKey: '6::::3000' },
       _idleTimeout: 120000,
       _idleNext:
        TimersList {
          _idleNext: [Circular],
          _idlePrev: [Circular],
          _timer: [Object],
          _unrefed: true,
          msecs: 120000 },
       _idlePrev:
        TimersList {
          _idleNext: [Circular],
          _idlePrev: [Circular],
          _timer: [Object],
          _unrefed: true,
          msecs: 120000 },
       _idleStart: 144720,
       parser:
        HTTPParser {
          '0': [Function: parserOnHeaders],
          '1': [Function: parserOnHeadersComplete],
          '2': [Function: parserOnBody],
          '3': [Function: parserOnMessageComplete],
          '4': [Function: onParserExecute],
          _headers: [],
          _url: '',
          _consumed: true,
          socket: [Circular],
          incoming: [Circular],
          outgoing: null,
          maxHeaderPairs: 2000,
          onIncoming: [Function: parserOnIncoming] },
       on: [Function: socketOnWrap],
       _paused: false,
       read: [Function],
       _consuming: true,
       _httpMessage:
        ServerResponse {
          domain: null,
          _events: [Object],
          _eventsCount: 1,
          _maxListeners: undefined,
          output: [],
          outputEncodings: [],
          outputCallbacks: [],
          outputSize: 0,
          writable: true,
          _last: false,
          upgrading: false,
          chunkedEncoding: false,
          shouldKeepAlive: true,
          useChunkedEncodingByDefault: true,
          sendDate: true,
          _removedHeader: [Object],
          _contentLength: 17,
          _hasBody: true,
          _trailer: '',
          finished: true,
          _headerSent: true,
          socket: [Circular],
          connection: [Circular],
          _header: 'HTTP/1.1 200 OK\r\nX-Powered-By: Express\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 17\r\nETag: W/"11-5i2g3OJs8No9M8PUhnLubxYJmZY"\r\nDate: Fri, 28 Apr 2017 00:06:49 GMT\r\nConnection: keep-alive\r\n\r\n',
          _headers: [Object],
          _headerNames: [Object],
          _onPendingData: [Function: updateOutgoingData],
          req: [Circular],
          locals: {},
          statusMessage: 'OK',
          statusCode: 200 } },
    connection:
     Socket {
       connecting: false,
       _hadError: false,
       _handle:
        TCP {
          bytesRead: 183,
          _externalStream: {},
          fd: 14,
          reading: true,
          owner: [Circular],
          onread: [Function: onread],
          onconnection: null,
          writeQueueSize: 0 },
       _parent: null,
       _host: null,
       _readableState:
        ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: [Object],
          length: 0,
          pipes: null,
          pipesCount: 0,
          flowing: true,
          ended: false,
          endEmitted: false,
          reading: true,
          sync: false,
          needReadable: true,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          defaultEncoding: 'utf8',
          ranOut: false,
          awaitDrain: 0,
          readingMore: false,
          decoder: null,
          encoding: null },
       readable: true,
       domain: null,
       _events:
        { end: [Object],
          finish: [Function: onSocketFinish],
          _socketEnd: [Function: onSocketEnd],
          drain: [Object],
          timeout: [Function],
          error: [Function: socketOnError],
          close: [Object],
          data: [Function: socketOnData],
          resume: [Function: onSocketResume],
          pause: [Function: onSocketPause] },
       _eventsCount: 10,
       _maxListeners: undefined,
       _writableState:
        WritableState {
          objectMode: false,
          highWaterMark: 16384,
          needDrain: false,
          ending: false,
          ended: false,
          finished: false,
          decodeStrings: false,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: false,
          bufferProcessing: false,
          onwrite: [Function],
          writecb: null,
          writelen: 0,
          bufferedRequest: null,
          lastBufferedRequest: null,
          pendingcb: 3,
          prefinished: false,
          errorEmitted: false,
          bufferedRequestCount: 0,
          corkedRequestsFree: [Object] },
       writable: true,
       allowHalfOpen: true,
       destroyed: false,
       _bytesDispatched: 222,
       _sockname: null,
       _pendingData: null,
       _pendingEncoding: '',
       server:
        Server {
          domain: null,
          _events: [Object],
          _eventsCount: 2,
          _maxListeners: undefined,
          _connections: 1,
          _handle: [Object],
          _usingSlaves: false,
          _slaves: [],
          _unref: false,
          allowHalfOpen: true,
          pauseOnConnect: false,
          httpAllowHalfOpen: false,
          timeout: 120000,
          _pendingResponseData: 0,
          _connectionKey: '6::::3000' },
       _server:
        Server {
          domain: null,
          _events: [Object],
          _eventsCount: 2,
          _maxListeners: undefined,
          _connections: 1,
          _handle: [Object],
          _usingSlaves: false,
          _slaves: [],
          _unref: false,
          allowHalfOpen: true,
          pauseOnConnect: false,
          httpAllowHalfOpen: false,
          timeout: 120000,
          _pendingResponseData: 0,
          _connectionKey: '6::::3000' },
       _idleTimeout: 120000,
       _idleNext:
        TimersList {
          _idleNext: [Circular],
          _idlePrev: [Circular],
          _timer: [Object],
          _unrefed: true,
          msecs: 120000 },
       _idlePrev:
        TimersList {
          _idleNext: [Circular],
          _idlePrev: [Circular],
          _timer: [Object],
          _unrefed: true,
          msecs: 120000 },
       _idleStart: 144720,
       parser:
        HTTPParser {
          '0': [Function: parserOnHeaders],
          '1': [Function: parserOnHeadersComplete],
          '2': [Function: parserOnBody],
          '3': [Function: parserOnMessageComplete],
          '4': [Function: onParserExecute],
          _headers: [],
          _url: '',
          _consumed: true,
          socket: [Circular],
          incoming: [Circular],
          outgoing: null,
          maxHeaderPairs: 2000,
          onIncoming: [Function: parserOnIncoming] },
       on: [Function: socketOnWrap],
       _paused: false,
       read: [Function],
       _consuming: true,
       _httpMessage:
        ServerResponse {
          domain: null,
          _events: [Object],
          _eventsCount: 1,
          _maxListeners: undefined,
          output: [],
          outputEncodings: [],
          outputCallbacks: [],
          outputSize: 0,
          writable: true,
          _last: false,
          upgrading: false,
          chunkedEncoding: false,
          shouldKeepAlive: true,
          useChunkedEncodingByDefault: true,
          sendDate: true,
          _removedHeader: [Object],
          _contentLength: 17,
          _hasBody: true,
          _trailer: '',
          finished: true,
          _headerSent: true,
          socket: [Circular],
          connection: [Circular],
          _header: 'HTTP/1.1 200 OK\r\nX-Powered-By: Express\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 17\r\nETag: W/"11-5i2g3OJs8No9M8PUhnLubxYJmZY"\r\nDate: Fri, 28 Apr 2017 00:06:49 GMT\r\nConnection: keep-alive\r\n\r\n',
          _headers: [Object],
          _headerNames: [Object],
          _onPendingData: [Function: updateOutgoingData],
          req: [Circular],
          locals: {},
          statusMessage: 'OK',
          statusCode: 200 } },
    httpVersionMajor: 1,
    httpVersionMinor: 1,
    httpVersion: '1.1',
    complete: false,
    headers:
     { host: 'localhost:3000',
       'user-agent': 'curl/7.43.0',
       accept: '*/*',
       'content-length': '23',
       'content-type': 'application/x-www-form-urlencoded' },
    rawHeaders:
     [ 'Host',
       'localhost:3000',
       'User-Agent',
       'curl/7.43.0',
       'Accept',
       '*/*',
       'Content-Length',
       '23',
       'Content-Type',
       'application/x-www-form-urlencoded' ],
    trailers: {},
    rawTrailers: [],
    upgrade: false,
    url: '/registerUser',
    method: 'POST',
    statusCode: null,
    statusMessage: null,
    client:
     Socket {
       connecting: false,
       _hadError: false,
       _handle:
        TCP {
          bytesRead: 183,
          _externalStream: {},
          fd: 14,
          reading: true,
          owner: [Circular],
          onread: [Function: onread],
          onconnection: null,
          writeQueueSize: 0 },
       _parent: null,
       _host: null,
       _readableState:
        ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: [Object],
          length: 0,
          pipes: null,
          pipesCount: 0,
          flowing: true,
          ended: false,
          endEmitted: false,
          reading: true,
          sync: false,
          needReadable: true,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          defaultEncoding: 'utf8',
          ranOut: false,
          awaitDrain: 0,
          readingMore: false,
          decoder: null,
          encoding: null },
       readable: true,
       domain: null,
       _events:
        { end: [Object],
          finish: [Function: onSocketFinish],
          _socketEnd: [Function: onSocketEnd],
          drain: [Object],
          timeout: [Function],
          error: [Function: socketOnError],
          close: [Object],
          data: [Function: socketOnData],
          resume: [Function: onSocketResume],
          pause: [Function: onSocketPause] },
       _eventsCount: 10,
       _maxListeners: undefined,
       _writableState:
        WritableState {
          objectMode: false,
          highWaterMark: 16384,
          needDrain: false,
          ending: false,
          ended: false,
          finished: false,
          decodeStrings: false,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: false,
          bufferProcessing: false,
          onwrite: [Function],
          writecb: null,
          writelen: 0,
          bufferedRequest: null,
          lastBufferedRequest: null,
          pendingcb: 3,
          prefinished: false,
          errorEmitted: false,
          bufferedRequestCount: 0,
          corkedRequestsFree: [Object] },
       writable: true,
       allowHalfOpen: true,
       destroyed: false,
       _bytesDispatched: 222,
       _sockname: null,
       _pendingData: null,
       _pendingEncoding: '',
       server:
        Server {
          domain: null,
          _events: [Object],
          _eventsCount: 2,
          _maxListeners: undefined,
          _connections: 1,
          _handle: [Object],
          _usingSlaves: false,
          _slaves: [],
          _unref: false,
          allowHalfOpen: true,
          pauseOnConnect: false,
          httpAllowHalfOpen: false,
          timeout: 120000,
          _pendingResponseData: 0,
          _connectionKey: '6::::3000' },
       _server:
        Server {
          domain: null,
          _events: [Object],
          _eventsCount: 2,
          _maxListeners: undefined,
          _connections: 1,
          _handle: [Object],
          _usingSlaves: false,
          _slaves: [],
          _unref: false,
          allowHalfOpen: true,
          pauseOnConnect: false,
          httpAllowHalfOpen: false,
          timeout: 120000,
          _pendingResponseData: 0,
          _connectionKey: '6::::3000' },
       _idleTimeout: 120000,
       _idleNext:
        TimersList {
          _idleNext: [Circular],
          _idlePrev: [Circular],
          _timer: [Object],
          _unrefed: true,
          msecs: 120000 },
       _idlePrev:
        TimersList {
          _idleNext: [Circular],
          _idlePrev: [Circular],
          _timer: [Object],
          _unrefed: true,
          msecs: 120000 },
       _idleStart: 144720,
       parser:
        HTTPParser {
          '0': [Function: parserOnHeaders],
          '1': [Function: parserOnHeadersComplete],
          '2': [Function: parserOnBody],
          '3': [Function: parserOnMessageComplete],
          '4': [Function: onParserExecute],
          _headers: [],
          _url: '',
          _consumed: true,
          socket: [Circular],
          incoming: [Circular],
          outgoing: null,
          maxHeaderPairs: 2000,
          onIncoming: [Function: parserOnIncoming] },
       on: [Function: socketOnWrap],
       _paused: false,
       read: [Function],
       _consuming: true,
       _httpMessage:
        ServerResponse {
          domain: null,
          _events: [Object],
          _eventsCount: 1,
          _maxListeners: undefined,
          output: [],
          outputEncodings: [],
          outputCallbacks: [],
          outputSize: 0,
          writable: true,
          _last: false,
          upgrading: false,
          chunkedEncoding: false,
          shouldKeepAlive: true,
          useChunkedEncodingByDefault: true,
          sendDate: true,
          _removedHeader: [Object],
          _contentLength: 17,
          _hasBody: true,
          _trailer: '',
          finished: true,
          _headerSent: true,
          socket: [Circular],
          connection: [Circular],
          _header: 'HTTP/1.1 200 OK\r\nX-Powered-By: Express\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 17\r\nETag: W/"11-5i2g3OJs8No9M8PUhnLubxYJmZY"\r\nDate: Fri, 28 Apr 2017 00:06:49 GMT\r\nConnection: keep-alive\r\n\r\n',
          _headers: [Object],
          _headerNames: [Object],
          _onPendingData: [Function: updateOutgoingData],
          req: [Circular],
          locals: {},
          statusMessage: 'OK',
          statusCode: 200 } },
    _consuming: false,
    _dumped: false,
    next: [Function: next],
    baseUrl: '',
    originalUrl: '/registerUser',
    _parsedUrl:
     Url {
       protocol: null,
       slashes: null,
       auth: null,
       host: null,
       port: null,
       hostname: null,
       hash: null,
       search: null,
       query: null,
       pathname: '/registerUser',
       path: '/registerUser',
       href: '/registerUser',
       _raw: '/registerUser' },
    params: {},
    query: {},
    res:
     ServerResponse {
       domain: null,
       _events: { finish: [Function: resOnFinish] },
       _eventsCount: 1,
       _maxListeners: undefined,
       output: [],
       outputEncodings: [],
       outputCallbacks: [],
       outputSize: 0,
       writable: true,
       _last: false,
       upgrading: false,
       chunkedEncoding: false,
       shouldKeepAlive: true,
       useChunkedEncodingByDefault: true,
       sendDate: true,
       _removedHeader: { 'content-length': false },
       _contentLength: 17,
       _hasBody: true,
       _trailer: '',
       finished: true,
       _headerSent: true,
       socket:
        Socket {
          connecting: false,
          _hadError: false,
          _handle: [Object],
          _parent: null,
          _host: null,
          _readableState: [Object],
          readable: true,
          domain: null,
          _events: [Object],
          _eventsCount: 10,
          _maxListeners: undefined,
          _writableState: [Object],
          writable: true,
          allowHalfOpen: true,
          destroyed: false,
          _bytesDispatched: 222,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: [Object],
          _server: [Object],
          _idleTimeout: 120000,
          _idleNext: [Object],
          _idlePrev: [Object],
          _idleStart: 144720,
          parser: [Object],
          on: [Function: socketOnWrap],
          _paused: false,
          read: [Function],
          _consuming: true,
          _httpMessage: [Circular] },
       connection:
        Socket {
          connecting: false,
          _hadError: false,
          _handle: [Object],
          _parent: null,
          _host: null,
          _readableState: [Object],
          readable: true,
          domain: null,
          _events: [Object],
          _eventsCount: 10,
          _maxListeners: undefined,
          _writableState: [Object],
          writable: true,
          allowHalfOpen: true,
          destroyed: false,
          _bytesDispatched: 222,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: [Object],
          _server: [Object],
          _idleTimeout: 120000,
          _idleNext: [Object],
          _idlePrev: [Object],
          _idleStart: 144720,
          parser: [Object],
          on: [Function: socketOnWrap],
          _paused: false,
          read: [Function],
          _consuming: true,
          _httpMessage: [Circular] },
       _header: 'HTTP/1.1 200 OK\r\nX-Powered-By: Express\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 17\r\nETag: W/"11-5i2g3OJs8No9M8PUhnLubxYJmZY"\r\nDate: Fri, 28 Apr 2017 00:06:49 GMT\r\nConnection: keep-alive\r\n\r\n',
       _headers:
        { 'x-powered-by': 'Express',
          'content-type': 'text/html; charset=utf-8',
          'content-length': '17',
          etag: 'W/"11-5i2g3OJs8No9M8PUhnLubxYJmZY"' },
       _headerNames:
        { 'x-powered-by': 'X-Powered-By',
          'content-type': 'Content-Type',
          'content-length': 'Content-Length',
          etag: 'ETag' },
       _onPendingData: [Function: updateOutgoingData],
       req: [Circular],
       locals: {},
       statusMessage: 'OK',
       statusCode: 200 },
    route:
     Route {
       path: '/registerUser',
       stack: [ [Object] ],
       methods: { post: true } } }
  </code></pre>
  
  <p>The question is where are my <code>username==test</code> and <code>foo=bar</code> gone? How do I access <code>req.data</code> or something like that?</p>
  
  <p>I'm looking at the documentation right now: <a href="https://nodejs.org/api/http.html#http_class_http_incomingmessage" rel="noreferrer">https://nodejs.org/api/http.html#http_class_http_incomingmessage</a> and it makes no sense, there's no single word about data I'm passing in my request and everything I care about is my data, that's what I'm working on, that's what I want to push to the MongoDB.</p>
  
  <p>I'm missing something big. Help? :)</p>