Notice
Recent Posts
Recent Comments
관리 메뉴

안까먹을라고 쓰는 블로그

[조코딩] [JavaScript 기초와 활용 #2] API의 개념과 활용! 카카오 책 검색 기능 구현하기 본문

카테고리 없음

[조코딩] [JavaScript 기초와 활용 #2] API의 개념과 활용! 카카오 책 검색 기능 구현하기

YawnsDuzin 2020. 2. 10. 22:52

 

반응형

 

https://developers.kakao.com/

 

Kakao Developers_

더 나은 세상을 꿈꾸고 그것을 현실로 만드는 이를 위하여 카카오에서 앱 개발 플랫폼 서비스를 시작합니다.

developers.kakao.com

※ 카카오 API를 사용하려면은 키를 받아서 데이터 요청시 참조해서 보내야 합니다.

 

kakao 책 검색 API

https://dapi.kakao.com/v3/search/book

 

 

https://code.jquery.com/

 

jQuery CDN

The integrity and crossorigin attributes are used for Subresource Integrity (SRI) checking. This allows browsers to ensure that resources hosted on third-party servers have not been tampered with. Use of SRI is recommended as a best-practice, whenever libr

code.jquery.com

 

<!DOCTYPE html>
<html lang="ko">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API 연습</title>
</head>

<body>
    <h1>내 사이트임 ㅎㅇ</h1>
    <p></p>
    <script src="https://code.jquery.com/jquery-3.4.1.js"
        integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>

    <script>
        $.ajax({
            method: "GET",
            url: "https://dapi.kakao.com/v3/search/book?target=title",
            data: { query:"미움받을 용기" },
            headers: {Authorization: "KakaoAK 1e08f2107796754de0b223b8b15e17e8"}
        })
            .done(function (msg) {
                // alert("Data Saved: " + msg);
                // console.log(msg.documents[0].title);
                // console.log(msg.documents[0].thumbnail);
                $( "p" ).append( "<strong>" + msg.documents[0].title + "</strong>" );
                $( "p" ).append( "<img src = '" + msg.documents[0].thumbnail + "'/>" );
            });
    </script>
</body>

</html>

 

Visual Studio Code - 코드 자동정리

Ctrl + A => Ctrl + K + F

 


https://www.youtube.com/watch?v=QPEUU89AOg8

 

반응형
Comments