Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Document</title>
- </head>
- <!-- <script src="script2.js" ></script> -->
- <body>
- <h1>Strona banku do wykoania przelewu</h1>
- <h2>Wysyłasz 1000 zł do Gigantów</h2>
- <button type="submit" onclick="send()">Wyslij Przelew</button>
- <button type="submit" onclick="sendGet()">GET</button>
- 7
- <script>
- function send() {
- const data = { amount: 1000, receiver: "Giganci" };
- console.log("Request: ", JSON.stringify(data));
- fetch("http://localhost:8081/bank", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(data),
- })
- .then((response) => response.json())
- .then((data) => {
- console.log("Success:", data);
- })
- .catch((error) => {
- console.error("Error:", error);
- });
- }
- function sendGet() {
- fetch("http://localhost:8081/hello")
- // .then((response) => response.json())
- .then((response) => {
- console.log("Success:", response);
- });
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement