<form action="#">
<input type="text" name="userName" class="input" placeholder="User-name">
<input type="password" name="password" class="input" placeholder="Password">
<input type="button" class="btn" value="Login">
</form>
document.querySelector('form').addEventListener('submit', function(e) {
e.preventDefault();
const data = Object.fromEntries(new FormData(this));
console.log(JSON.stringify(data, null, 2));
});