Failed to execute 'fetch' on 'Window': Invalid name at HTMLFormElement.
При попытке сделать fetch-запрос получаю ошибку:
Failed to execute 'fetch' on 'Window': Invalid name at HTMLFormElement.< anonymous>
<h1>Подтвердите смену пароля</h1>
<form>
<input type="password">
<input type="submit">
</form>
<script>
const input = document.querySelector('input');
const form = document.querySelector('form');
form.addEventListener('submit', ev => {
ev.preventDefault();
console.log(3)
debugger
fetch('http://localhost:5500/api/auth/passwordRecovery', {
method: "POST",
headers: {
"Content-Type ": "application/x-www-form-urlencoded"
},
body: JSON.stringify({
email: '[email protected]',
oldPassword: 'token',
newPassword: input.value
})
}).then(res => res.json()).then(res => console.log(res));
});
</script>
Первый раз сталкиваюсь с этой ошибкой и понятия не имею, что с этим делать и как её решить.