I'm trying to figure out how to display information from an API in a select.
The user has to select a start station with the itself linked to the api. But I can't create option, having the names of each station, in my select.
Can you help me understand my mistake?
<section class="container">
<div class="item">
<p>list</p>
<select id="subwaystation">
</select>
var apiStations = "https://api-ratp.pierre-grimaud.fr/v4/stations/metros/8";
function req1() {
fetch(apiStations, {
method: "get"
})
.then(response => response.json())
.then(data => {
let allstations= data.result.stations;
for(var i = 0; i < allstations.length; i++) {
html += "<option value=" + key + ">" +obj[key] + "</option>"
}
document.getElementById("subwaystation").innerHTML = html;
})
}
req1();