Reputation: 175
I wrote a very basic controller like
@Controller('tasks')
export class TasksController {
constructor(private tasksService: TasksService) {}
@Get(':id')
getById(@Param('id') id: string): TaskDto {
console.log('Get Called>>>', id);
const task = this.tasksService.getById(id);
const dto = TaskMapper.toDto(task);
return dto;
}
@Delete(':id')
remove(@Param('id') id: string): void {
console.log('Delete Called>>>', id);
this.tasksService.remove(id);
}
}
I'm using the following URI to call each endpoint via Postman (also tried with the Powershell) with their respective METHOD GET, DELETE.
http://localhost:3000/tasks/83b213a0-8cbf-46e0-a484-e3df7f216e2f
Now, the strangest thing is that CLI is somehow got stuck at one version of the Controller file. Now even if I delete the whole controller, the cli is still mapping the different methods of the Controller.
I've tried different methods of starting the application via various yarn, npm and directly nest commands but nothing seems to pick up the latest file changes.
I've gone through the whole code a zillion times but unable to pinpoint the issue!
Upvotes: 2
Views: 1390
Reputation: 1
I previously encountered such an issue i tried removing the dist file, reinstalling the node_modules, setting the maximum number of watch files for my computer, I even went further restarting my computer but what worked for was moving the action
@Get(':id')
getById(@Param('id') id: string): TaskDto {
console.log('Get Called>>>', id);
const task = this.tasksService.getById(id);
const dto = TaskMapper.toDto(task);
return dto;
}
below
@Delete(':id')
remove(@Param('id') id: string): void {
console.log('Delete Called>>>', id);
this.tasksService.remove(id);
}
try to swap the order of these controller actions and test it.
Upvotes: 0
Reputation: 175
Finally got it working, solution was to delete the "dist" folder.
But I still don't understand why this problem occurred in the first place!!
Upvotes: 3