Skip to content

Commit

Permalink
๐Ÿ”ง fix: ์ฃผ์„์ฒ˜๋ฆฌ ํ–ˆ๋˜ ์ฝ”๋“œ๋ฅผ logger๋กœ ๋ณ€๊ฒฝ#12
Browse files Browse the repository at this point in the history
  • Loading branch information
uuuo3o committed Nov 6, 2024
1 parent 3c1ffcb commit 4375e5f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions BE/src/stocks/topfive/topfive.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { Injectable } from '@nestjs/common';
import { Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { StockRankigRequestDto } from './dto/stock-ranking-request.dto';
import { StockRankingResponseDto } from './dto/stock-ranking-response.dto';
Expand Down Expand Up @@ -56,6 +56,8 @@ export class TopFiveService {
baseUrl: string;
};

private readonly logger = new Logger();

constructor(private readonly config: ConfigService) {
this.koreaInvestmentConfig = {
appKey: this.config.get<string>('KOREA_INVESTMENT_APP_KEY'),
Expand Down Expand Up @@ -86,7 +88,6 @@ export class TopFiveService {
}

private async requestApi(params: StockRankigRequestDto) {
// eslint-disable-next-line no-useless-catch
try {
const token = await this.getAccessToken();

Expand Down Expand Up @@ -121,19 +122,18 @@ export class TopFiveService {
);
return response.data;
} catch (error) {
// console.error('API Error Details:', {
// status: error.response?.status,
// statusText: error.response?.statusText,
// data: error.response?.data,
// headers: error.response?.config?.headers, // ์‹ค์ œ ์š”์ฒญ ํ—ค๋”
// message: error.message,
// });
this.logger.error('API Error Details:', {
status: error.response?.status,
statusText: error.response?.statusText,
data: error.response?.data,
headers: error.response?.config?.headers,
message: error.message,
});
throw error;
}
}

async getMarketRanking(marketType: MarketType) {
// eslint-disable-next-line no-useless-catch
try {
const params = new StockRankigRequestDto();
params.fid_cond_mrkt_div_code = 'J';
Expand Down Expand Up @@ -171,13 +171,13 @@ export class TopFiveService {

return response;
} catch (error) {
// console.error('API Error Details:', {
// status: error.response?.status,
// statusText: error.response?.statusText,
// data: error.response?.data,
// headers: error.response?.config?.headers, // ์‹ค์ œ ์š”์ฒญ ํ—ค๋”
// message: error.message,
// });
this.logger.error('API Error Details:', {
status: error.response?.status,
statusText: error.response?.statusText,
data: error.response?.data,
headers: error.response?.config?.headers, // ์‹ค์ œ ์š”์ฒญ ํ—ค๋”
message: error.message,
});
throw error;
}
}
Expand Down

0 comments on commit 4375e5f

Please sign in to comment.