#Uknown Column but other where cases are working
1 messages · Page 1 of 1 (latest)
it worked but i dont undertstand why i mean what is difference if get id route was above
can you explain?
':id' is a wildcard route matcher, essentially a '*' where it captures what that value is. So when you call GET /getEnded it matches the ':id' route first and doesn't make it to your other route handler
Where is @Get('getOne') in your controller?
import {Controller, Get, Body, Param, UseGuards} from '@nestjs/common';
import { TechnologiesService } from "./technologies.service";
import {AuthGuard} from "@nestjs/passport";
@Controller('technologies')
export class TechnologiesController {
constructor(private readonly technologiesService: TechnologiesService) {}
@UseGuards(AuthGuard('jwt'))
@Get('getAll')
getAll() {
return this.technologiesService.getAll()
}
@UseGuards(AuthGuard('jwt'))
@Get('getEnded')
getEnded() {
return this.technologiesService.findByLevel()
}
@UseGuards(AuthGuard('jwt'))
@Get('/:id')
getOne(@Param('id') id: string) {
return this.technologiesService.getOne(+id)
}
}
Ah, did you call getended or getEnded?
i call getEnded but i dont understand why this wildcard works like this if it means * if i call getEnded why it still checks /:id
This is after moving theroute and re-compiling and restarting the server, right?
What isn't clear?
can you explain me more why wildcard works like this like why it was not working when getone was written before getended
It's just how express runs through the routes. It checks each one that the router is aware of and checks "does this url match the route?" So, in the old case
- Make
GET /technoligies/getEnded - Match
technologiesrouter - Iterate over
getOne,:id,getEnded, etc - Does
getEndedmatchgetOne? No, move on - Does
getEndedmatch:id? This is essnetially a regex of.*so yes, it matches, call this handler - Return the response from the handler and stop checking other paths