@Get()
Maps a controller method to an HTTP GET request for the given path.
Syntax
@Get(path?: string | string[]) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
path | string | string[] | No | Optional route path appended to the controller prefix. Supports wildcards and params. |
Returns
MethodDecorator — A decorator applied to the route handler method.
Examples
import { Controller, Get, Param } from '@nestjs/common';
@Controller('cats')
export class CatsController {
@Get()
findAll() {
return ['kitty'];
}
@Get(':id')
findOne(@Param('id') id: string) {
return { id };
}
}
Notes
GET handlers should be idempotent and side-effect free. Route params are
declared with the `:name` syntax and read via @Param(). The return value
is serialized to JSON automatically with a 200 status code.