Skip to content

Commit

Permalink
Fix: navigation API 예외처리
Browse files Browse the repository at this point in the history
  • Loading branch information
sw0501 committed Nov 28, 2023
1 parent 40501ae commit 2a6c785
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions BackendJS/BackendTS/routes/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,16 @@ router.get('/:startX/:startY/:endX/:endY/:type', (req, res) => __awaiter(void 0,
method: 'GET'
}, function (error, response, body) {
return __awaiter(this, void 0, void 0, function* () {
if (JSON.parse(body).hasOwnProperty("error")) {
console.error(JSON.parse(body).error);
return res.status(500).json({
error: JSON.parse(body).error
});
}
//JSON parse
const NavigationList = JSON.parse(body).result;
//console.log(error);
//console.log(response);
//1. 도보 시간, 2. 환승 개수, 3. 총 이동 시간
NavigationList.path.sort((a, b) => {
if (a.info.totalWalk === b.info.totalWalk) {
Expand Down
12 changes: 11 additions & 1 deletion BackendTS/routes/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,20 @@ router.get('/:startX/:startY/:endX/:endY/:type',async(req:Request,res:Response)=
method: 'GET'
}, async function (error:Error, response:any, body:string) {

if(JSON.parse(body).hasOwnProperty("error")){
console.error(JSON.parse(body).error);
return res.status(500).json({
error: JSON.parse(body).error
})
}

//JSON parse
const NavigationList:NavigationResult = JSON.parse(body).result;


//console.log(error);
//console.log(response);


//1. 도보 시간, 2. 환승 개수, 3. 총 이동 시간
NavigationList.path.sort((a:NavigationPath, b:NavigationPath)=>{
if(a.info.totalWalk === b.info.totalWalk){
Expand Down

0 comments on commit 2a6c785

Please sign in to comment.