Advertisement
sphinx2001

35-index.html

May 5th, 2023
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.67 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>FastAPI получение данных из объектов.</title>
  5.         <meta charset="utf-8" />
  6.     </head>
  7.     <body>
  8.         <div id="message"></div>
  9.             <button onclick="send()">Отправить</button>
  10.         <script>
  11.             async function send() {
  12.                 const response = await fetch("/hello", {
  13.                     method: "POST",
  14.                     headers: { "Accept": "application/json", "Content-Type": "application/json" },
  15.                     body: JSON.stringify([
  16.                         { name: "Tom", age: 38 },
  17.                         { name: "Bob", age: 41 },
  18.                         { name: "Sam", age: 25 }
  19.                         ])
  20.                     });
  21.                 const data = await response.json();
  22.                 console.log(data);
  23.             }
  24.         </script>
  25.     </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement