const login = document.querySelector('.auth__input--login').value;
const password = document.querySelector('.auth__input--password').value;
const button = document.querySelector('.auth__button');
button.onclick = (e) =>{
e.preventDefault();
mainFunc();
}
async function mainFunc(){
let url = 'https://авторизация';
data ={
'username': login,
'password': password
}
let responce = await fetch(url, {data: data, mode: "no-cors", method: 'POST'});
let result = await responce.json();
if(result == true){
console.log(result.username);
console.log(result.password);
} else{
console.log('аккаунт не найден!');
}
}
document.querySelector('.auth__button').addEventListener('click', auth);
async function auth() {
event.preventDefault();
var login = document.querySelector('.auth__input--login').value;
var password = document.querySelector('.auth__input--password').value;
var form = new FormData();
form.append('username', login);
form.append('password', password);
var url = 'https://авторизация';
var response = await (await fetch(url, { method: 'POST', body: form })).text();
console.log('Ответ сервера', response);
}