Public
Edited
Nov 9, 2022
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fetchData = async (name) => {
const fUrl = `https://api.pantheon.world/person?name=eq.${name}`;
return await fetch(fUrl).then((response) => response.json());
}
Insert cell
viewof fetched = Inputs.button("Fetch data", {value: [], reduce: () => {
return doFetch();
}});

Insert cell
fetched
Insert cell
doFetch = async () => {
let data = [];

for (let i = 0; i < selectedStore.length; i++) {
await new Promise(r => setTimeout(r, 600));
data.push(await fetchData(selectedStore[i].name));
}

return data;
}
Insert cell
Inputs.button("copy selection", {value: null, reduce: () => navigator.clipboard.writeText(JSON.stringify(fetched)) })
Insert cell
Insert cell
massaged = example_data.map(d => d[0])
Insert cell
makeCard = (data) => {

return `- #card ${data.name} was born in ${data.bplace_name}, ${data.bplace_country} in \{\{cloze ${data.birthyear}\}\} and died in \{\{cloze ${data.deathyear}\}\} (aged: ${data.deathyear - data.birthyear})
- ${data.famous_for}`
}
Insert cell
makeCard(massaged[0])
Insert cell

Inputs.button("copy cards", {value: null, reduce: () => navigator.clipboard.writeText(massaged.map(makeCard).join("\n")) })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more