i'm working on project update in which dashboard page is having more than 3, 000 lines of code.
i want to persist the previous working
so i want to convert this function
  returnUserDetails(){
       var userDetails = JSON.parse(localStorage.getItem("userData"));
       return userDetails ;      
     }
to this one but giving error of undefined return value
 returnUserDetails(){
    var userData;
    this.storage.get('userData').then((val) => {
         userData = JSON.parse(val);  
     });
   return userData; 
 }
Question: i cannot use global variable as this function used so many times. how can i return value correctly
 
     
     
    