@Put()
Maps a controller method to an HTTP PUT request for the given path.
Syntax
@Put(path?: string | string[]) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
path | string | string[] | No | Optional route path appended to the controller prefix. |
Returns
MethodDecorator — A decorator applied to the route handler method.
Examples
import { Controller, Put, Param, Body } from '@nestjs/common';
@Controller('cats')
export class CatsController {
@Put(':id')
replace(@Param('id') id: string, @Body() dto: any) {
return { id, ...dto };
}
}
Notes
PUT is used to fully replace a resource and should be idempotent. For
partial updates prefer @Patch().