data = {
const json = await d3.json(
`${endpoint}
?get=${variables.join(",")}
&for=county:${counties.join(",")}
&in=state:${states.join(",")}`
.replace(/\n/gi, "")
.replace(/ /gi, "")
);
const transformed = json.slice(1).map((row) =>
row.reduce((acc, cur, i) => {
acc[headers[i]] = i < 6 ? +cur : cur;
return acc;
}, {})
);
transformed.forEach((d) => {
d.fips = `${d.state}${d.county}`;
d.ratio_with =
(d.with_subscription + d.without_subscription) / d.total_households;
d.ratio_without = d.without_internet_access / d.total_households;
delete d.state;
delete d.county;
});
return transformed;
}