In home.html, change;
data2.stamp to data2["stamp"]
and same with data2.free
In home.html, change;
data2.stamp to data2["stamp"]
and same with data2.free
I am calling two API endpoints which returns the following
api1 = [
{
"size": "SMUS",
"price": "0.02"
},
{
"size": "LGUK",
"price": "0.0045"
},
{
"size": "SMUK",
"price": "0.0018"
},
{
"size": "LGUS",
"price": "0.05260"
},
{
"size": "XLUK",
"price": "0.00299"
},
{
"size": "XLUS",
"price": "0.060"
}]
api2 = {
"r1": 176,
"r2": 125,
"r3": 0,
"stock": [
{
"stamp": "LG",
"free": "472",
"return": "0"
},
{
"asset": "MD",
"free": "238",
"return": "0"
},
{
"asset": "SM",
"free": "47",
"return": "0"
},
{
"asset": "XL",
"free": "6880",
"return": "0"
}
],
"view": [
"HIGH"
]}
Now I am trying to get the data into a table. I am using Flask templates, so i have the table on my home.html file with the following code for the table body.
<tbody>
{% for data2 in api2['stock'] %}
{% for data1 in api1 %}
{% if data2['stamp'] in (data1['size'])[:-2].strip() %}
<tr>
<td>{{ data2.stamp }}</td>
<td>{{ data2.free }}</td>
<td>{{ data1['price'] }}</td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
</tbody>
I am not getting an error, however when the table renders it displays many rows of ‘stamp’ data and the data is all messed up.
I would like the table to provide — stamp – free – price
Thank you for any help
Thank you for the reply, but I don’t understand as there’s no “data” so I cannot replace “data2” with “data” or am I missing something
Oh sorry that is data2. You don’t have to change data2 .
I tried that but it didn’t solve my problem… The table still is not being formatted correctly with the data.