<!DOCTYPE html>
<html>

  <head>
    <title>Star wars</title>
    <script src="https://d3js.org/d3.v4.min.js"></script>
    <link rel="stylesheet" href="style.css" />
  </head>

  <body>
    <h1>Récupérer les planètes</h1>
    <ul id = "planetes"></ul>
    <script src="script.js"></script>
  </body>

</html>
var q = d3.queue();
for (i = 1; i <= 7; i++) {
  q.defer(d3.json, "https://swapi.co/api/planets/?page=" + i);
}

q.awaitAll(function(error, results) {
  if (error) throw error;
  var donnees = results.map(function(e) { return e.results; })
    .reduce(function(a, b) {
      return a.concat(b);
    });
  d3.select("#planetes").selectAll("li")
    .data(donnees)
    .enter()
    .append("li")
    .html(function (p) {
      return p.name;
    })
});
/* Styles go here */