How to have the update info form already filled with the user informations when he logs in?

I have a local storage where the users are saved. After they login i have a part in the page where they have to update their infos. How to have the form already filled with their info after they login?

I have this function and i do not know where to go from here:

function populateForm() {

  let userData = JSON.parse(localStorage.getItem('userData')) || [];
  if (userData) {

      document.getElementById('firstName').value = userData.firstName;
      document.getElementById('lastName').value = userData.lastName;
      document.getElementById('username').value = userData.username;
      document.getElementById('birthDate').value = userData.birthDate;
      document.getElementById('email').value = userData.email;
  }

}