-
Book Overview & Buying
-
Table Of Contents
Learn D3.js - Second Edition
By :
To load a resource from a page, its location must be specified as a relative or absolute URL. If you installed this book’s repository as a project in WebStorm or Visual Studio, the document root of your IDE’s web server is the repository’s root. For example, to access the Paris2024.csv file from this chapter’s data/ folder, you would use the following absolute URL:
/Part2/Chapter05/data/Paris2024.csv
For most of the code examples in this book, where each chapter contains its own data, we will use relative URLs, as they will be shorter. For the code examples in this section, stored in Chapter05/Fetching/, we assign the file’s relative URL to a constant, as follows:
const dataFile = "../data/Paris2024.csv";
You can now load the text and print it to the console using fetch() (see Fetching/1-dom-fetch.html):
fetch(dataFile) .then(response => response.text()) ...