# QueryParams Decorator

Module
import { QueryParams } from "@tsed/common"
Source/packages/common/src/mvc/decorators/params/queryParams.ts

# Overview

function QueryParams(expression: string, useType: Type<any>): ParameterDecorator;
function QueryParams(expression: string): ParameterDecorator;
function QueryParams(useType: Type<any>): ParameterDecorator;
function QueryParams(options: IParamOptions<any>): ParameterDecorator;
function QueryParams(): ParameterDecorator;
Param Type Description
expression string The path of the property to get. useType

# Description

QueryParams return the value from request.query object.

# Example

@Controller('/')
class MyCtrl {
   @Get('/')
   get(@QueryParams() query: any) {
      console.log('Entire query', query);
   }

   @Get('/')
   get(@QueryParams('id') id: string) {
      console.log('ID', id);
   }

   @Get('/')
   get(@QueryParams('user') user: User) { // with deserialization
      console.log('user', user);
   }

   @Get('/')
   get(@QueryParams('users', User) users: User[]) { // with deserialization
      console.log('users', users);
   }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

For more information on deserialization see converters page.