score:3

Accepted answer

topojson.feature takes two parameters, as seen in the topojson doc's:

topojson.feature(topology, object);

You have only specified the objects you wish to extract:

 let counties = topojson.feature(data[0].objects.counties);

The error likely derives from the lack of a second parameter: type is undefined for the second parameter since the second parameter is not defined.

Using both parameters, you can extract your features without error using both parameters below:

let counties = topojson.feature(data[0], data[0].objects.counties);

const promisses = [d3.json('https://raw.githubusercontent.com/no-stack-dub-sack/testable-projects-fcc/master/src/data/choropleth_map/counties.json'), d3.json('https://raw.githubusercontent.com/no-stack-dub-sack/testable-projects-fcc/master/src/data/choropleth_map/for_user_education.json')];

Promise.all(promisses).then((d)=>{return processData(d)});

function processData(data) {
  for (let i = 0; i < data.length; i++) {
    //console.log(JSON.stringify(data[i]));
  }
  
  let w = 800;
  let h = 0.6 * w;
  let padding = 40;
  
  let svg = d3.select('#chart-bg').append('svg');
  
  svg.attr('width', w + 2 * padding)
    .attr('height', h + 2 * padding)
    .attr('id','map')
  
  
  //The next line is where I am having trouble
  let counties = topojson.feature(data[0], data[0].objects.counties);
  console.log(JSON.stringify(counties));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>


Related Query

More Query from same tag