최정민

FEAT : ajax버튼을 이용한 api

-
......@@ -277,8 +277,8 @@ router.get("/recommend", function (req, res) {
if (err) {
console.log(err);
} else if (row.length > 0) {
console.log(row);
res.send(row);
console.log(row[0].CAFE_ID);
res.send({result:row});
}
});
}
......
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622591147463,"user":{"email":"cjm2021401@khu.ac.kr","picture":"https://lh3.googleusercontent.com/a/AATXAJzFD3R6CaL2NpysVrfvdGqcQ83vh_wpbN_5hj-0=s96-c","nickname":"초보베이시스트","age":16,"gender":"male"}}
\ No newline at end of file
......@@ -158,6 +158,8 @@
<div class="col-1"></div>
</div>
<button type="button" id='Recommend' class="btn btn-primary" onclick="recommend();">추천</button>
<p id='test'></p>
</section>
<script
......@@ -165,6 +167,22 @@
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=68cbccbcd6f0fef0a213e62ad37393ee&libraries=services"
></script>
<script>
function recommend(){
$.ajax({
url: '/recommend',
type: 'GET',
success:function (result){
if (result) {
$('#test').html(result.result[0].CAFE_ID);
}
}
});
}
</script>
<script>
var lat = "";
var lon = "";
var placeOverlay = new kakao.maps.CustomOverlay({ zIndex: 1 });
......