Skip to content

Commit

Permalink
submit email corrects
Browse files Browse the repository at this point in the history
  • Loading branch information
TetiZ committed Feb 1, 2024
1 parent e011390 commit 497ee05
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/js/submit-email-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ import 'izitoast/dist/css/iziToast.min.css';
const form = document.querySelector('.subs-form');
const localStorageKey = 'user-email';

const savedEmail = localStorage.getItem(localStorageKey);

if (savedEmail) {
form.elements.email.value = savedEmail;
} else {
form.elements.email.value = '';
}

form.addEventListener('input', saveToLocalStorage);

function saveToLocalStorage(evt) {
localStorage.setItem(localStorageKey, evt.target.value);
}

const savedEmail = localStorage.getItem(localStorageKey);

form.elements.email.value = savedEmail ? savedEmail : '';

async function postEmail(userEmail) {
try {
const response = await fetch(
Expand Down

0 comments on commit 497ee05

Please sign in to comment.