Body

Route handler parameter decorator. Extracts the entire body object property, or optionally a named property of the body object, from the req object and populates the decorated parameter with that value. Also applies pipes to the bound body parameter.

See more...


 @Body(property?: string | PipeTransform<any, any> | Type<PipeTransform<any, any>>, ...pipes: (PipeTransform<any, any> | Type<PipeTransform<any, any>>)[])

Parameters

Option Type Description
property string | PipeTransform | Type>

name of single property to extract from the body object


Optional. Default is `undefined`.
pipes (PipeTransform | Type>)[]

one or more pipes - either instances or classes - to apply to the bound body parameter.

Returns

ParameterDecorator

See also

Description

For example:


async create(@Body('role', new ValidationPipe()) role: string)