Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Insert title here</title>
- </head>
- <body>
- <div id="bookInfo"></div>
- <script>
- function GetURLParameter(sParam)
- {
- var sPageURL = window.location.search.substring(1);
- var sURLVariables = sPageURL.split('&');
- for (var i = 0; i < sURLVariables.length; i++)
- {
- var sParameterName = sURLVariables[i].split('=');
- if (sParameterName[0] == sParam)
- {
- return sParameterName[1];
- }
- }
- }
- fetch('http://localhost:8080/rest/books/'+GetURLParameter('id'))
- .then(function (response) {
- return response.json();
- })
- .then(function (data) {
- id = data.id;
- appendData(data);
- })
- .catch(function (err) {
- console.log(err);
- });
- function appendData(data) {
- var text = "";
- text += "<div class="info" id="info">";
- text += "<h1>"+"<strong>Ttile:"+data.title + "</strong> </h1>";
- //text += "<strong>Post By: </strong>"+data.owner.username;
- text+= "<br/>";
- text += "<strong>Author: </strong>"+data.author;
- text+= "<br/>";
- text += "<strong>Release date: </strong>"+data.year;
- text+= "<br/>";
- text += "<strong>Rate: </strong>"+data.rating;
- text+= "<br/>";
- document.getElementById("bookInfo").innerHTML = text;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement