When I send this specific URL from my Angular application:
http://localhost:3000/api/skills?category_id=2
The main issue revolves around how to modify the code in order to successfully retrieve all skills with a category_id of 2. It is important to note that just fetching the skill_id individually is not the goal here. Each record contains the following fields:
skill_id
skill_name
category_id
Within the skills.controller file, I have made attempts to use the @Get param for this purpose, without success. The console.log function never seems to be triggered. Furthermore, I am unclear on how to instruct the service to fetch all skill records matching a specified category_id.
@Get('?category_id')
public async getSkillsByCategory(@Param('category_id') categoryId) {
console.log('skills recordId in controller: ', categoryId.id);
return this.skillsService.getSkillsByCategory(categoryId.id);
}
Inside the skills.service file, there exists a method aimed at retrieving skills based on their category_id. However, it does not effectively communicate this requirement to the database, particularly Postgres. It appears that a different approach is necessary due to the unique behavior of the category_id column.
async getSkillsByCategory(categoryId) {
console.log('categoryId in service', categoryId);
return await this.skillsRepository.find(categoryId);
}