Advertisement
yepesd86

html_lambda

May 24th, 2025 (edited)
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.36 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="es">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Formulario API Lambda</title>
  7.     <script>
  8.         // Función para enviar datos a la API
  9.         async function enviarDatos() {
  10.             // Captura el valor del campo de nombre
  11.             const nombre = document.getElementById("nombre").value;
  12.            
  13.             // Verifica que el campo no esté vacío
  14.             if (nombre.trim() === "") {
  15.                 alert("Por favor, ingresa un nombre");
  16.                 return;
  17.             }
  18.  
  19.             // Enviar los datos a la API
  20.             const response = await fetch("TU_URL_DE_API_GATEWAY/hello", {
  21.                 method: "POST",
  22.                 headers: {
  23.                     "Content-Type": "application/json"
  24.                 },
  25.                 body: JSON.stringify({ name: nombre })
  26.             });
  27.  
  28.             // Procesar la respuesta
  29.             const data = await response.json();
  30.             alert(data.message); // Mostrar mensaje recibido de la API
  31.         }
  32.     </script>
  33. </head>
  34. <body>
  35.     <h2>Formulario de Inserción de Datos</h2>
  36.     <label for="nombre">Nombre:</label>
  37.     <input type="text" id="nombre" name="nombre" placeholder="Ingrese su nombre">
  38.     <button onclick="enviarDatos()">Enviar</button>
  39. </body>
  40. </html>
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement