I have created bootstrap carousel with fetched images from API json. Everything works but I can't add active item to the first slide and normal item to the rest. I'm still a beginner and any help will be appreciated.
serverInfo = {
"levelshotsArray": [
"https://picsum.photos/200",
"https://picsum.photos/200/300?grayscale", "https://picsum.photos/200"
]
}
serverInfo.levelshotsArray.map(res => {
var imge = document.createElement('img');
imge.src = res;
imge.height = 100;
imge.width = 100;
imge.alt = "";
document.getElementById('img').appendChild(imge);
});
<div class="carousel" id="Carousel" data-ride="carousel">
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target="#Carousel">
<li data-slide-to="1" data-target="#Carousel">
</ol>
<div class="carousel-inner" role="listbox">
<div id="img" class="carousel-item active"></div>
</div>
</div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>