here is the mapping which displaying the all the data i have to put check if body contains nulll then dont display them.any help would be apprecited
{logs &&
logs.map((log, value) =>
Object.keys(log.body).map((key) => (
<tr key={key}>
<td>{key}</td>
<td>{JSON.stringify(log.body[key])}</td>
</tr>
))
)}
And here is the API.
[
{
"id": 1,
"body": {
"buy_WBNB": 0.1231,
"sell_WBNB": 0.1541,
"expected_profit": -42.27542384981283,
},
"response": "CONNECTION ERROR: The connection got closed with the close code `4040`",
"created_at": "Feb 28, 2022 11:57 AM"
},
{
"id": 2011,
"body": null,
"response": "connection not open on send()",
"created_at": "Feb 28, 2022 5:49 PM"
},
]
>Solution :
check first log.body exist
{logs &&
logs.map((log) =>
log.body && Object.keys(log.body).map((key) => (
<tr key={key}>
<td>{key}</td>
<td>{JSON.stringify(log.body[key])}</td>
</tr>
))
)}
