Incoming Request Data

Use the request object to access incoming request data. Napkin parses incoming requests to your endpoint and stores the data in the request object. The object API is defined below.

req.body

type: Object

Contains key-value pairs of data submitted in the request body if the incoming Content-Type was application/json

req.cookies

type: Object

Contents of all cookies transmitted in the request

req.data

type: String

Contains the incoming request data as a string in case it came it came with a non-application/json Content-Type header.

req.form

type: Object

Contains key-value pairs of incoming form data if the incoming Content-Type request header is multipart/form-data

req.get(field)

type: Function

Return the value for the HTTP request header field field (case-insensitive match).

req.headers

type: Object

Contains the incoming request headers as key-value pairs

req.method

type: String

The HTTP method of the incoming request

req.param

type: Function

Returns the value for the given path parameter, or undefined if no such parameter exists in the request

req.params

type: Object

Contains key-value pairs of the path parameters of the incoming request

req.path

type: String

The path part of the request URL

req.query

type: Object

Contains key-value pairs for any query parameters present in the incoming request route