How to send REST API to html page


#1

what is the best method to get REST API input/output to html pages. Can i make REST api calls natively from html ? or do i need any language like php/javascript.


#2

HTML is a markup language as opposed to a programming language, so you would indeed require any programming language that has access to HTTP client libraries. You also want something that can be easily integrated with HTML pages, so Javascript and PHP are popular choices amongst many.


#3

Can some one help me on how to write a simple query for GET query like mentioned in the training modules but i want to include authentication and also accept the self signed certificates.


#4

Extensive documentation is found at
https://xhr.spec.whatwg.org/#the-open()-method

put a button on your website (on the html code), this button will have a function on javascript to GET something from somewhere, you need to define those, based on the responses and documentation of the API you are trying to hit.

<body>
<button onclick="getResponse()">the button text</button>

<script>
function getResponse(){
  var request = new XMLHttpRequest();
  request.open("GET", "TARGET URL (EX http://127.0.0.1:8000/)", false(async flag), "userName", "password");
  request.send();
}
</script>
</body>