title: Using IONIC Storage Service, how to get and return stored JSON data?
body: <p>I’m new to Ionic. </p>
  
  <p>I'm able to store A JSON object (data) using IONIC Storage Service; however, when I try to retrieve the JSON data, I get undefined.</p>
  
  <p>I appreciate any help on this - below is my code:</p>
  
  <p>Provider: storage-service.ts:
  I’m able to store and output data, but I cannot return the data:</p>
  
  <pre><code>import {Injectable} from '@angular/core';
  import { Storage } from '@ionic/storage';
  
  @Injectable()
  export class StorageService {
  
  constructor(public storage: Storage){}
  
  public storeData (data) {
      this.storage.set('data', data);
  }
  
  public getStoredData() {
           this.storage.get('data').then((val) =&gt; {
          console.dir(val);  //****** this outputs the object.
          return val;  //***** this returns undefined
          });
    }
   }
  </code></pre>
  
  <p>my-page.ts:</p>
  
  <pre><code>import {StorageService} from "../../providers/storage-service";
  
  constructor(public storageService: StorageService) {
  
      //***** this outputs undefined, what I'm doing wrong?
      console.dir(this.storageService.getStoredData());
  }
  </code></pre>
  
  <p>Any help on this is greatly appreciated.</p>
  
  <p>Thank you</p>