From ffd05f3c055a035fa7a9f348b4fbd232f2e030e7 Mon Sep 17 00:00:00 2001 From: Sangwook Park <41150708+sw0501@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:47:50 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=97=86=EB=8A=94=20=EC=A7=80=ED=95=98?= =?UTF-8?q?=EC=B2=A0=EC=97=AD=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BackendTS/routes/subwaydata.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/BackendTS/routes/subwaydata.ts b/BackendTS/routes/subwaydata.ts index fcef989..53171d3 100644 --- a/BackendTS/routes/subwaydata.ts +++ b/BackendTS/routes/subwaydata.ts @@ -45,7 +45,7 @@ function getSubwayStationName(stNm:string, callback:(nameList:Arrayvoid) { +function getSubwayStationInfo(stCd:string, stNm:string, callback:(stationInfo:SubwayStationInfo|null)=>void) { try { const connection:mysql.connection = db.return_connection(); @@ -57,12 +57,10 @@ function getSubwayStationInfo(stCd:string, stNm:string, callback:(stationInfo:Su console.log(err); } - /* //NULL error - if (results.length !== 0) { - return callback(); + if (results.length === 0) { + return callback(null); } - */ const url:string = 'https://openapi.kric.go.kr/openapi/convenientInfo/stationInfo'; let queryParams:string = '?' + encodeURI('serviceKey'); @@ -544,9 +542,17 @@ router.get('/stationInfo/:stCd/:stNm', async (req:Request, res:Response) => { const stNm = req.params.stNm; await getSubwayStationInfo(stCd, stNm, stationinfo => { - return res.status(200).json({ - stationinfo - }) + if(stationinfo === null){ + return res.status(500).json({ + error: "No Station" + }) + } + + else{ + return res.status(200).json({ + stationinfo + }) + } }) } catch (e) { @@ -673,7 +679,7 @@ router.get('/transferMove/transferList/:stCd/:stNm/:railCd/:lnCd', async (req:Re await getTransferList(stCd, stNm, railCd, lnCd, transferInfo => { if (transferInfo.sourceStation.length === 0 || transferInfo.transferStation.length === 0) { return res.status(500).json({ - error: 404, + error: 500, errorString: "Not Transfer Station" }) }