elections-cpl.api.hscc.bdpa.org • Docs
elections-cpl.api.hscc.bdpa.org / lib/next-adhesive/add-raw-body / default
default(
req
,res
,context
):Promise
<void
>
Adds a rawBody
property onto the NextApiRequest object, which contains the
raw unparsed content of the request body if it exists or undefined
if it
does not. The body is still parsed (using bodyParser
) like normal using a
custom implementation of Next.js's parseBody
function.
To use this middleware, bodyParser
must be disabled via Next.js API route
configuration like so:
export const config = {
api: {
bodyParser: false
},
}
Note that this middleware cannot be used with other middleware or routes that also directly consume the request body in a special way, such as when using streams.
• req: NextApiRequest
• res: NextApiResponse
• context: MiddlewareContext
<Options
>
Promise
<void
>
https://nextjs.org/docs/api-routes/api-middlewares#custom-config