Skip to content

Commit 3ddca3f

Browse files
committed
update the second API
1 parent a1c63da commit 3ddca3f

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

project/app.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ function fetchCovidSummary() {
4242
return axios.get(url);
4343
}
4444

45+
/**
46+
*
47+
* @param {'spain' | 'switzerland'} countryCode 스페인과 스위스만 지원됩니다.
48+
* @returns
49+
*/
4550
function fetchCountryInfo(countryCode, status) {
4651
// params: confirmed, recovered, deaths
47-
const url = `https://api.covid19api.com/country/${countryCode}/status/${status}`;
52+
const url = `https://ts-covid-api.vercel.app/api/country/${countryCode}`;
4853
return axios.get(url);
4954
}
5055

@@ -77,20 +82,28 @@ async function handleListClick(event) {
7782
clearRecoveredList();
7883
startLoadingAnimation();
7984
isDeathLoading = true;
80-
const { data: deathResponse } = await fetchCountryInfo(selectedId, 'deaths');
81-
const { data: recoveredResponse } = await fetchCountryInfo(
82-
selectedId,
83-
'recovered',
84-
);
85+
86+
console.log({selectedId});
87+
88+
/**
89+
* NOTE: 코로나 종식으로 오픈 API 지원이 끝나서 death, recover 데이터는 지원되지 않습니다.
90+
* 그리고 국가별 상세 정보는 "스페인"과 "스위스"만 지원됩니다.
91+
*/
92+
// const { data: deathResponse } = await fetchCountryInfo(selectedId, 'deaths');
93+
// const { data: recoveredResponse } = await fetchCountryInfo(
94+
// selectedId,
95+
// 'recovered',
96+
// );
8597
const { data: confirmedResponse } = await fetchCountryInfo(
8698
selectedId,
8799
'confirmed',
88100
);
89101
endLoadingAnimation();
90-
setDeathsList(deathResponse);
91-
setTotalDeathsByCountry(deathResponse);
92-
setRecoveredList(recoveredResponse);
93-
setTotalRecoveredByCountry(recoveredResponse);
102+
// NOTE: 코로나 종식으로 오픈 API 지원이 끝나서 death, recover 데이터는 지원되지 않습니다.
103+
// setDeathsList(deathResponse);
104+
// setTotalDeathsByCountry(deathResponse);
105+
// setRecoveredList(recoveredResponse);
106+
// setTotalRecoveredByCountry(recoveredResponse);
94107
setChartData(confirmedResponse);
95108
isDeathLoading = false;
96109
}
@@ -168,8 +181,6 @@ async function setupData() {
168181

169182
function renderChart(data, labels) {
170183
var ctx = $('#lineChart').getContext('2d');
171-
Chart.defaults.color = '#f5eaea';
172-
Chart.defaults.font.family = 'Exo 2';
173184
new Chart(ctx, {
174185
type: 'line',
175186
data: {

0 commit comments

Comments
 (0)