Javascript - access variable in then outside it's scope : <p>I have the following Javascript and I am trying to access the <strong>content</strong> data out of the service scope, what's the best way to access that data?</p>

<pre><code>Service
.getContent()
.then((content = {}) =&gt; {//access this content out of 'Service' scope})
.catch((error = {})  =&gt; {console.log('errror', error)})
</code></pre>

<p>I tried the following: </p>

<pre><code>let data = null;
Service
.getContent()
.then((content = {}) =&gt; {data = content})
.catch((error = {})  =&gt; {console.log('errror', error)})
console.log(data);
</code></pre>

<p>But I get the error that data is undefined. How can I get the contents of <strong>content</strong> to <strong>data</strong> </p>
