Znote (recipes)
  Get Znote  

Integrate dataset online

How to integrate dataset online with your note


Integrate dataset online

If your data comes from a URL or a private database, you can use a dedicated code block to retrieve and write your dataset locally. The noDeploy parameter indicates to omit this block of code when publishing the note

You can also add the parameter hide to hide the code block from your online report.

Write dataset locally

const r = await fetch('https://www.govtrack.us/api/v2/role?current=true&role_type=senator')
const json = await r.json();
//const json = await sqlDatabase("SELECT...");
_fs.writeFileSync(__dirname + "/senators-dataset.json", JSON.stringify(json));

Publish note with a local file The files parameter indicates that the file must be included when publishing

const senators = require("./senators-dataset.json");
showDatagrid({data: senators.objects.map(e=>e.person), pagination: true});

Go further with dynamic data

To go further, below is a complete advanced example showing how to deploy a block of code as a Node API that connects to a remote database and returns JSON on a private URL. 👉 premium

Related recipes