function click_send(){ data = document.getElementById("inp1").value; console.log(data); fetch("http://localhost:5556/add/"+data).then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.text(); }).then(result => { console.log(result); const res = document.createElement("p"); res.textContent = data + " => " + "localhost:5556/" + result; document.body.appendChild(res); }) return 10 * 3; } document.addEventListener("DOMContentLoaded", function () { const input = document.getElementById("inp1"); input.addEventListener("keydown", function (event) { if (event.key === "Enter") click_send(); }); });