new to JS and I'm trying to wrap my head around Promises that I could use some insight.
let urlPath = "some urlpath with data"
let data = d3.csv(urlPath).then(function (d) {
console.log(d); // Prints data as expected
});
My goal is that I want the function to return the data into the DATA variable so that I can continue to execute on it further down in the code. So something similar to below:
let data = d3.csv(urlPath).then(function (d) { return d; });
//....do more things with data....
console.log(data); // returns Promise { pending }
But the code keeps giving me Promise {pending}. Any ideas how I can resolve the promise so that I get what I'm looking for? Thanks,