I've a controller xyz.controller.ts
@Get()
fetch(
@Query('id') id: number,
@Query('status') status: string,
@Query('country_id') countryId: number,
@Query('state_id') stateId: number): Promise<any> {
return await this.xyzService(id, status, countryId, stateId);
}
Is there any way to pass the query params as a single object instead of creating multiple function args?
if you specify the key in the query, it will only return the value of that key, but if you just write @Query() query
it will return the whole query object and then you can create a interface to give a type to the query object, @Query() query: IQuery
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.