From a487c3ea145ced3b4d7a16136e4a47c8db5e51d3 Mon Sep 17 00:00:00 2001 From: SJY Date: Wed, 4 Sep 2024 03:34:47 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=99=98=EC=9C=A8=20api=EB=B3=80?= =?UTF-8?q?=EA=B2=BD,=20=EB=82=A0=EC=A7=9C=20=EC=B5=9C=EC=8B=A0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Checklist.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pages/Checklist.js b/src/pages/Checklist.js index 77e28da..d2ec171 100644 --- a/src/pages/Checklist.js +++ b/src/pages/Checklist.js @@ -7,10 +7,20 @@ import styles from '../styles/Checklist.module.css'; function Checklist() { const [data, setData] = useState([]); + // 오늘 날짜 + const today = new Date(); + const year = today.getFullYear(); + const month = (today.getMonth() + 1).toString().padStart(2, '0'); + const day = (today.getDate()-1).toString().padStart(2, '0'); + // yyyymmdd 형식으로 변환 + const currentDate = year + month + day; + console.log("currentDate: " + currentDate); + useEffect(() => { const fetchUsers = async () => { + // API URL - const apiURL = '/api/site/program/financial/exchangeJSON?authkey=' + process.env.REACT_APP_JAPAN_API_KEY + '&searchdate=20240903&data=AP01' + const apiURL = '/api/site/program/financial/exchangeJSON?authkey=' + process.env.REACT_APP_JAPAN_API_KEY + '&searchdate=' + currentDate + '&data=AP01' if(process.env.REACT_APP_JAPAN_API_KEY) { console.log("API key is set " + process.env.REACT_APP_JAPAN_API_KEY[0]); } @@ -19,9 +29,11 @@ function Checklist() { if (!response.ok) { throw new Error('Network response was not ok'); } + console.log(response); const result = await response.json(); // 응답을 JSON으로 변환 const japaneseYenData = result.find(item => item.cur_nm === "일본 옌"); setData(japaneseYenData); + console.log(japaneseYenData); } catch (error) { console.error('There was a problem with the fetch operation:', error); } @@ -50,7 +62,7 @@ function Checklist() {

일본은 '엔'을 쓰기 때문에 환전을 해서 가야한다!

실시간 환율을 알아보고 환전 하자!

-

{data.date} {data.time} 기준

+

{currentDate} 기준

(100엔 당)