ajax example

by Destan Sarpkaya

JavaScript

fetch('localhost:8080/demo')
	   .then(response => {
       if (!response.ok) {
           throw new Error("HTTP error " + response.status);
       }
       return response.json();
   })
   .then(json => {
       alert(json)
       console.log(json);
   })
   .catch(function (e) {
       alert(e)
   })