Woopii Vyeolog

[HTML, JS] 간단하게 테스트 할 수 있는 API Client 본문

html,css,js

[HTML, JS] 간단하게 테스트 할 수 있는 API Client

WooPii 2022. 11. 17. 01:43

## Github URL : https://github.com/leewoopyo/TestApiClient

 

GitHub - leewoopyo/TestApiClient

Contribute to leewoopyo/TestApiClient development by creating an account on GitHub.

github.com

 

 

 

1. 소스코드

TestApiClient.html

<!DOCTYPE html>
<html>
  <body>
    <button onclick="callApi()">클릭</button>
    <div id="show_result"></div>
    <script>
      function callApi() {
        //Header
        const config = {
          method: "get"
        };
        //Call Api
        fetch("http://localhost:19001/verification/api/info/java-version", config)
          .then(response => response.json())
          .then(data => {
                    console.log(data);

                    const div_data = document.createElement("div");
                    const show_result = document.getElementById("show_result");

                    div_data.textContent = JSON.stringify(data);

                    show_result.appendChild(div_data);
                })
          .catch(error => console.log(error));
      }
    </script>
  </body>
</html>

 

 

 

'html,css,js' 카테고리의 다른 글

mouseover 시 slide 애니메이션을 가진 메뉴바  (0) 2020.02.12
Comments