How use type with QueryParams #2092
Answered
by
Romakita
sjarrossay
asked this question in
Q&A
-
Hello, I try to use type with QueryParams
But I've got this error:
How can I fix it, to work with type ? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Answered by
Romakita
Sep 16, 2022
Replies: 1 comment
-
Type as now consistency in js. So typescript convert type to Object (as metadata). Prefer enum usage: export type MyType = 'type1' | 'type2';
export class MyController {
@Get('/')
async tryType(@QueryParams('type') @Enum('type1', 'type2') type: MyType) {
}
} Better Alternative: export enum MyEnum {
TYPE_1 = "type1",
TYPE_2 = "type2"
}
export class MyController {
@Get('/')
async tryType(@QueryParams('type') @Enum(MyEnum) type: MyEnum) {
}
} see you |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Romakita
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Type as now consistency in js. So typescript convert type to Object (as metadata). Prefer enum usage:
Better Alternative:
see you