Good evening everyone,
I write this message to ask your help regarding a project that deals with the display of information on a web page which come from an API. More precisely, it’s about showing the destination and the waiting times of trains from Lyon train station. I’ve wrote down on a code already and I don’t know what’s wrong with it. If someone could help me, that’d be wonderful.
Here’s the API : https://api-ratp.pierre-grimaud.fr/v4/schedules/metros/1/gare-de-lyon/R
Here’s the html code :
Assignment 2<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css"
/>
<link rel="stylesheet" href="style.css" />
Metros' destinations and waiting times
<div class="row">
<p id="destination" class="six columns">
Destination
</p>
<p id="message" class="six columns">
Waiting time
</p>
</div>
<div id="schedules" class="container"></div>
<p>
Data can be found here :
<a
href="https://api-ratp.pierre-grimaud.fr/v4/schedules/metros/1/gare-de-lyon/R" target="_blank"
>
Datalink</a
>
</p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="main.js"></script>
Here’s the JS code :
$.getJSON(
“https://api-ratp.pierre-grimaud.fr/v4/schedules/metros/1/gare-de-lyon/R”,
function(json) {
console.log(json.features[0].destination.message);
var schedules = json.features;
for (var i = 0; i < schedules.length; i = i + 1) {
var schedules = schedules[i];
var html=
‘
’ +
schedules.properties.destination +
‘
’ +
schedules.properties.message +
“
$("#schedules").append(html)
;
}
}
);
Thank you very much in advance !