I am trying to create a service to be able to filter the books by categories,I can't get the query parameter to the book service
Book controller
@ApiTags('books')
@Controller('book')
export class BookController {
constructor(private readonly getBook: GetBookApi) {}
@Get()
@ApiOperation({
description: 'Return Books from Api',
});
async findAll(@Query() input:GetBookInputDto):Promise<BookDTO[]> {
return await this.getBook.category(input.category);
}
}
But I can't get the query parameter to the book service
// Book Service
@Injectable()
export class BookService {
constructor(private readonly client: BookClient) {}
async getCategorys(): Promise<Book[]> {
const result = await this.client.get();
if (result && result.data && !result.data.error) {
return BookAdapter.mapperBookResponse(result.data);
} else {
throw new UnauthorizedException('Error getting
identifiers
');
}
}
}
here I have the client book where I have the url using axios
async get() {
const host = 'http://www.etnassoft.com/api/v1/'
const path = 'get?category=libros';
const newInstance = axios.create({
baseURL: host,
timeout: 10000,
headers: {
Accept: 'application/json',
},
});
const request: AxiosResponse = await newInstance({
method: 'get',
url: path,
});
return request;
}
}