title: How to fetch api data and view in HTML table
body: <p>In my code, I want to fetch data from api and view in html table using javascript.</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>fetch("http://dummy.restapiexample.com/api/v1/employees").then(
    res =&gt; {
      res.json().then(
        data =&gt; {
          console.log(data);
          if (data.length &gt; 0) {
  
            var temp = "";
            data.forEach((itemData) =&gt; {
              temp += "&lt;tr&gt;";
              temp += "&lt;td&gt;" + itemData.id + "&lt;/td&gt;";
              temp += "&lt;td&gt;" + itemData.employee_name + "&lt;/td&gt;";
              temp += "&lt;td&gt;" + itemData.employee_salary + "&lt;/td&gt;";
            });
            document.getElementById('data').innerHTML = temp;
          }
        }
      )
    }
  )</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;table class="table"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;ID&lt;/th&gt;
          &lt;th&gt;Employee Name&lt;/th&gt;
          &lt;th&gt;Salary&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody id="data"&gt;
  
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>The api data can view but when I want to view those data to html table is shows nothing. any idea how I show those fetched data into the html table.</p>