Skip to content

CookiesParams

@tsed/platform-params

Usage

typescript
import { CookiesParams } from "@tsed/platform-params";

See /packages/platform/platform-params/src/types/decorators/cookies.ts.

Overview

ts
function CookiesParams(expression: string | any, useType: any): ParameterDecorator;
export function CookiesParams(): ParameterDecorator;
export function CookiesParams(expression: string | any): ParameterDecorator;
export function CookiesParams(options: ParamOptions<any>): ParameterDecorator;
  • expression (string | any): The path of the property to get.

  • useType (any): The type of the class that to be used to deserialize the data.

Description

Cookies or CookiesParams return the value from request.cookies object.

Example

typescript
@Controller('/')
class MyCtrl {
   @Post('/')
   create(@Cookies() cookies: any) {
      console.log('Entire cookies', cookies);
   }

   @Post('/')
   create(@Cookies('id') id: string) {
      console.log('ID', id);
   }

   @Post('/')
   create(@Cookies('user') user: IUser) {
      console.log('user', user);
   }
}

For more information on deserialization see converters page.

Released under the MIT License.