Hey there! I'm currently diving into the world of JavaScript, and it's been quite a journey these past 3 days as I've been attempting to get everything up and running. Despite its apparent simplicity, I can't seem to make things click.
My current challenge involves organizing data that I fetch from an API.
I'm making API requests using axios
axios.get('url').then(function (response) {
console.log(response.data)
})
The JSON response I receive looks like this
[{
"item_id": "item_1",
"city": "city_1",
"quality": 2,
"sell_price": 1000,
"sell_price_date": "2020-05-05T01:20:00"
},
// More JSON objects
]
My goal is to structure the data in the following format:
[{
"item_id": "item_1",
"qualities": [
{
"quality": 2,
"cities": [
// City details
]
},
// More quality levels
],
},
// More item entries
]
After organizing the data, my plan is to create HTML elements dynamically based on the structured data (pseudo code)
<ul class="items" >
${db.forEach(item => {
<li class="item">
<p class="item_title">item.item_id</p>
<ul class="item_qualities">
${item.qualities.forEach(qual => {
<li class="quality">
<p class="quality_title">qual.quality</p>
<ul class="cities">
${qual.cities.forEach(city => {
<li class="city">
<p class="city_title">city.city</p>
<ul class="prices">
<li class="sell_price">
<p class="sell_price_title">city.sell_price</p>
</li>
<li class="sell_price_date">
<p class="sell_price_date_title">city.sell_price_date</p>
</li>
</ul>
</li>
})}
</ul>
</li>
})}
</ul>
</li>
})}
</ul >
In conclusion
As a newbie in the realm of programming and JavaScript, I'm eager to learn by working with real-world APIs. Any guidance or tutorials you could recommend regarding JSON and database handling would be greatly appreciated!