title: Get data from Json by using javascript (jsonplaceholder)
body: <p>I've been trying to print the Json file's data on a HTML page. I need to import these data:</p>
  <p><a href="https://jsonplaceholder.typicode.com/posts/1" rel="nofollow noreferrer">https://jsonplaceholder.typicode.com/posts/1</a></p>
  <p>I was trying to use this code to get the data from the file:</p>
  <p><a href="https://github.com/typicode/jsonplaceholder#how-to" rel="nofollow noreferrer">https://github.com/typicode/jsonplaceholder#how-to</a></p>
  <p>This is what I wrote in my function:</p>
  <p>JS:</p>
  <pre><code>function req1() {
  fetch('https://jsonplaceholder.typicode.com/posts/1')
    .then(response =&gt; response.json())
    .then(json =&gt; console.log(json))
          // we print the title and the body of the post recived
      var title = response.data.title;
      var body = response.data.body
      document.getElementById(&quot;printTitle&quot;).innerHTML = title
      document.getElementById(&quot;printBody&quot;).innerHTML = body
  }
  </code></pre>
  <p>HTML:</p>
  <pre><code>&lt;div class=&quot;news-btn-div&quot; data-tab=&quot;news-2&quot; onclick=&quot;req1()&quot;&gt;2&lt;/div&gt;
  
      &lt;div id=&quot;news-2&quot; class=&quot;news-content-container-flex&quot;&gt;
        &lt;div class=&quot;news-title&quot;&gt;
          &lt;span id=&quot;printTitle&quot;&gt;
          &lt;/span&gt;
        &lt;/div&gt;
        &lt;div class=&quot;news-content-1&quot;&gt;
          &lt;span id=&quot;printBody&quot;&gt;
          &lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  <p>So I should get the data once I click on .news-btn-div DIV but I don't get where I'm making the mistake.</p>
  <h1>printTitle and #printBody DIVS should be populated with data.</h1>
  <p>Any advice?</p>
  <p>Here my Jsfiddle:</p>
  <p><a href="https://jsfiddle.net/matteous1/ywh0spga/" rel="nofollow noreferrer">https://jsfiddle.net/matteous1/ywh0spga/</a></p>