title: How to store fetch response in javascript variable
body: <p>sorry for the basic question.
  I was trying using fetch to get data from api and want to store that response into a javascript variable but its not working as I have expected
  My code-</p>
  <pre><code>async function fun() {
      var a = &quot;initial&quot;;
      fetch('https://jsonplaceholder.typicode.com/todos/1')
          .then(res =&gt; res.json())
          .then(data =&gt; {
              a = data;
              console.log(a);
          })
  
      await console.log(&quot;Response =&gt; &quot;, a);
  }
  </code></pre>
  <p>Output - Response =&gt; initial</p>
  <p>What is the correct way of doing this.</p>