Skip to content

Commit

Permalink
fix: 예외처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
constmoon committed Sep 1, 2020
1 parent 03f30d2 commit 99e1b40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion hooks/useTodayGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const useTodayGame = () => {
const gameList = await fetchGameList(team);
const date = new Date;
const index = date.getDate() - 1;
if (gameList[index].hasOwnProperty('away') && gameList[index].away.score === null) {
// 경기가 존재하고 아직 시작 전이면 전날 경기 표시
if (gameList[index].hasOwnProperty('away') && gameList[index].away.score === null && index > 1) {
const prevGame = gameList[index - 1];
setTodayGame(prevGame);
}
Expand Down
2 changes: 1 addition & 1 deletion pages/api/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default async (req, res) => {
const awayTeam = game.querySelector('.team_lft').text || '';
const homeTeam = game.querySelector('.team_rgt').text || '';
const isLive = game.querySelector('.td_btn a').toString().includes('btn_wd_on');
const isEnd = game.querySelector('.td_btn a').toString().includes('경기결과') || game.querySelectorAll('.td_btn a').toString().includes('경기영상');
const isEnd = game.querySelector('.td_btn a').toString().includes('경기결과');
const [awayScore, homeScore] = game.querySelector('.vs') ? [null, null] : game.querySelector('.td_score').text.split(':');

return ({
Expand Down

1 comment on commit 99e1b40

@vercel
Copy link

@vercel vercel bot commented on 99e1b40 Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.