title: Is there a way to Reference a non-public Variable outside function(API)
body: <p>I am working with the CoinMarketCap API and have managed to setup and get server response and am getting the values that I need using the following code</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>request('GET','https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?CMC_PRO_API_KEY=' + apikey.key + '&amp;symbol=BTC,LTC').then((r1) =&gt; {
      var x1 = JSON.parse(r1.target.responseText);
      console.log(x1);
  
      var json = {
          BTC: x1.data.BTC.quote.USD.price,
          LTC: x1.data.LTC.quote.USD.price,
      }
      console.log(json.BTC, json.LTC);
  
  }).catch(err =&gt; {
      console.log(err);
  })  </code></pre>
  </div>
  </div>
  </p>
  <p>Is there a way that I can refer me 'var json' outside the function or in any other file, if not is there any other way I could get the same values without using this method of linking to the server which would allow me to make these public variables</p>
  <p>I cannot by default make it a public variable as to when I do so <code>x1</code> will not be found and making <code>x1</code> public the <code>r1</code> would not be found</p>
  <p>Hope the question made sense, I am fairly new to this stuff</p>