How to return a promise?
<p>I am writing an Angular app. I need method getData()  to always return a promise. So if data is retrieved from local storage and it is not null it should be returned as promise without calling $http.get part. </p>

<p>How do I write it?</p>

<pre><code>getData() {
      var data = localStoradge.getItem('data');
      if (data == null) {
        return $http.get('url').then(function(response){
          data = response;
          return data
          })
        }
    }
</code></pre>