Read a file and make div's based on the content of the file. best approach

Hello, I have to read a json file so I do it like this :

fetch('./data.json)
.then( (resp) => resp.json())
.then( (data) => result = data)

fetch('./data.json)
.then( (resp) => resp.json())
.then( (data) => result = data)

now I have to make a div with these contents for every object
<div class="reaction card">
<div class="left">
<img src="./assets/images/icon-reaction.svg">
<p>Reaction</p>
</div>
<div class="right">
<span class="bold">80 </span>
<p> / 100</p>
</div>
</div>
<div class="reaction card">
<div class="left">
<img src="./assets/images/icon-reaction.svg">
<p>Reaction</p>
</div>
<div class="right">
<span class="bold">80 </span>
<p> / 100</p>
</div>
</div>
Is it wise to call a function in my fetch or is there a way I can use the data outside the fetch
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server