The subject line is pretty much it.
I have a NestJS-based REST API server. I want to process a query parameter like so:
http://localhost:3000/todos?complete=false
I can't seem to work out how to have the controller process that.
right now I have:
@Get()
async getTodos(@Query('complete') isComplete: boolean) {
const todosEntities = await this.todosService.getTodosWithComlete(isComplete);
const todos = classToPlain(todosEntities);
return todos;
}
but that always returns the completed todos, not the ones where complete = false.
Here's the call to getTodosWithComlete:
async getTodosWithComplete(isComplete?: boolean): Promise<Todo[]> {
return this.todosRepository.find({
complete: isComplete,
isDeleted: false,
});
}
How do I return the proper todos based on a query parameter?