How to integrate online Datasets with your note
If your data comes from a URL or a private database, you can retrieve and save it locally using a dedicated code block.
This example fetches data from an API and saves it as a local JSON file.
// Fetch data from API
const r = await fetch('https://www.govtrack.us/api/v2/role?current=true&role_type=senator');
const json = await r.json();
// Alternative: Retrieve data from an SQL database
// const json = await sqlDatabase("SELECT ...");
// Write data to a local file
_fs.writeFileSync(__dirname + "/senators-dataset.json", JSON.stringify(json));
print("✅ Dataset saved locally as 'senators-dataset.json'");
The files parameter ensures that the dataset file is included when publishing.
// Load the dataset from the local file
const senators = require("./senators-dataset.json");
// Display data in a table
showDatagrid({
data: senators.objects.map(e => e.person),
pagination: true
});