How to load two external files in D3?

Solution 1:

d3.json in d3 v7 returns a promise, so what you wrote is almost correct. Just that the second argument isn't for manipulating data (it's for passing additional options to the fetch call: see fetch() API). d3.json uses the browser's inbuilt fetch() API.

To manipulate data you will have to do it in the then callback function.

Promise.all([
    d3.json('file01.json'),
    d3.json('file02.json')
]).then(function([data01, data02]){

  // manipulate data here
  // data01
  // data02
})

See working example in this codepen Check console for data being logged after being fetched.