// The problem is on the next line or something.
let data = d3.json("https://raw.githubusercontent.com/freeCodeCamp/ProjectReferenceData/master/GDP-data.json", function(d) {
return d
})
console.log(data)
The line with console.log(data) always outputs {} instead of the data given.
Can someone tell me how to fix this?
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Challenge Information:
Data Visualization Projects - Visualize Data with a Bar Chart
async function dataGet() {
let data = await d3.json("https://raw.githubusercontent.com/freeCodeCamp/ProjectReferenceData/master/GDP-data.json")
return data
}
console.log(dataGet())
Ilenia offered you some very helpful advice. Checking out a project dealing with promises and asynchronous programming when you’re stumped about them is a solid strategy. You get to learn what you need to before getting back to the current project.
Here’s a hint. The dataGet method is returning a promise which hasn’t been fulfilled yet. Hence why nothing is printing in the console.
P.S For the record, please don’t create another thread while actively ignoring helpful advice one of our staff members. I can understand being stumped. I can understand being confused and bumping the thread. Your response was very rude and I don’t appreciate it.