title: How to render python dictionary values in Javascript Fetch API (forEach)?
body: <p>I am trying to render python dictionary values inside a Javascript Fetch API. I tried various ways to do so such as serializing values and using dictionary keys to access the dictionary values. I got no error message but the values I rendered are all &quot;undefined&quot; on my webpage.</p>
  <p>Python</p>
  <pre><code>def portfolio_position(request):
  positions = Portfolio.objects.filter(owner=request.user, off_portfolio=False).order_by('-symbol').values()
  return JsonResponse([position for position in positions], safe=False)
  </code></pre>
  <p>Javascript</p>
  <pre><code>function load_portfolio_position() {
    fetch('/portfolio_position')
    .then(response =&gt; response.json())
    .then(positions =&gt; {
        console.log(positions);
        var table = document.getElementById(&quot;portfolio-table&quot;);
        positions.forEach(position =&gt; {
          var row = table.insertRow(1);
          row.id = `row_${position.symbol}`;
          var symbol = row.insertCell(0);
          var price = row.insertCell(1);
          var change = row.insertCell(2);
          var average_cost = row.insertCell(3);
          var position = row.insertCell(4);
          var pnl = row.insertCell(5);
          var pnl_percent = row.insertCell(6);
          symbol.innerHTML = `${position.symbol}`; 
          price.innerHTML = `${position.price}`; 
          change.innerHTML = `${position.change}`; 
          var avc = parseFloat(position.cost).toFixed(3);
          average_cost.innerHTML = `${avc}`; 
          position.innerHTML = `${position.position}`;
          pnl.innerHTML = `${position.pnl}`;
          pnl_percent.innerHTML = `${position.pnl_percent}`;
        });
    })
  }
  </code></pre>
  <p><img src="https://i.stack.imgur.com/tjlhR.png" alt="This is the dictionary with values from console log" /></p>
  <p><img src="https://i.stack.imgur.com/SVJ6Z.png" alt="This is the undefined result I got in my webpage" /></p>
  <p>Appreciate your help!</p>