title: Ionic 3 How to ensure db data fetched before view is loaded
body: <p>I'm using token based authentication and token is already saved on DB.</p>
  
  <p>When app starts, I need to fetch the token from DB and make it available before making API calls. </p>
  
  <p>What is best way to do it:</p>
  
  <p>In Component:</p>
  
  <pre><code>ngOnit() {
  storage.get('token').then((val) =&gt; {
      Make api call here 
  });
  }
  </code></pre>
  
  <p>Or in shared service:</p>
  
  <pre><code>getToken() {
      return Promise((resolve, reject)=&gt;{
         #if fetched once save in local var and resolve token  
         #or fetch from DB and resolve token  
      })
  }
  
  // On Component
  this.sharedService.getToken().then((token)=&gt;{
    //Make api call
  }
  </code></pre>
  
  <p>Is there any way I can ensure the DB token is fetched and store in shared services before view is loaded? The storage.get is a 'ES6 promise'</p>
  
  <p>Concern is responsibility of loading token before loading view is escalated to any bootstrapping event, so onViewLoad doesn't needs to be defined in each component.</p>