You have 2 options:
(1) provide a callback:
d3.csv("titanic_data.csv", function(error, data) {
if (error) {
console.log("something went wrong", error);
} else {
console.log("data: ", data);
}
})
or
(2) invoke get:
d3.csv("titanic_data.csv")
.get(function(error, data) {
if (error) {
console.log("something went wrong", error);
} else {
console.log("data: ", data);
}
})
Why this way? From d3.csv documentation:
d3.csv(url[[, accessor], callback])
Issues an HTTP GET (...) The request is processed asynchronously, such that this method returns immediately after opening the request. When the CSV data is available, the specified callback will be invoked with the parsed rows as the argument.