d3.json, d3.csv, d3.tsv, d3.text, d3.xml and d3.image wrap fetch() and return promises (an optional init passes headers through). d3.csv yields strings unless a row function converts them; d3.autoType infers numbers, booleans, null and ISO dates. Serve the demo folder with python -m http.server:
<script src="https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js"></script>
<script type="module"> // module scripts allow await
const data = await d3.json('booknest-sales.json');
console.log(`JSON: ${data.books.length} books, ${data.sales.length} sales rows`);
const rows = await d3.csv('booknest-sales.csv', d3.autoType);
console.log(`CSV: ${rows.length} rows, first:`, JSON.stringify(rows[0]));
await d3.json('missing.json').catch(err => console.log('missing.json:', err.message));
</script>JSON: 6 books, 106 sales rows
CSV: 106 rows, first: {"month":"2025-01-01T00:00:00.000Z","book":1,"units":48}
missing.json: 404 File not foundautoType made "2025-01" a UTC Date. Unlike raw fetch, which resolves on a 404, d3-fetch rejects any response that isn't OK.