Advertisement
Mihao

bank

Oct 27th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>Document</title>
  8. </head>
  9. <!-- <script src="script2.js" ></script> -->
  10. <body>
  11. <h1>Strona banku do wykoania przelewu</h1>
  12. <h2>Wysyłasz 1000 zł do Gigantów</h2>
  13. <button type="submit" onclick="send()">Wyslij Przelew</button>
  14. <button type="submit" onclick="sendGet()">GET</button>
  15.  
  16. 7
  17.  
  18. <script>
  19. function send() {
  20. const data = { amount: 1000, receiver: "Giganci" };
  21. console.log("Request: ", JSON.stringify(data));
  22. fetch("http://localhost:8081/bank", {
  23. method: "POST",
  24. headers: {
  25. "Content-Type": "application/json",
  26. },
  27. body: JSON.stringify(data),
  28. })
  29. .then((response) => response.json())
  30. .then((data) => {
  31. console.log("Success:", data);
  32. })
  33. .catch((error) => {
  34. console.error("Error:", error);
  35. });
  36. }
  37. function sendGet() {
  38. fetch("http://localhost:8081/hello")
  39. // .then((response) => response.json())
  40. .then((response) => {
  41. console.log("Success:", response);
  42. });
  43. }
  44. </script>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement