Hi all!
When I try to run the following code in node
import * as ObStdLib from '@observablehq/stdlib'
import * as Plot from '@observablehq/plot'
const { FileAttachment } = new ObStdLib.Library()
async function generateGraph() {
return FileAttachment("athletes.json").json().then(athletes =>
Plot.rectY(athletes, Plot.binX({y: "count"}, {x: "weight", fill: "sex"})).plot()
)
}
const graphPromise = generateGraph()
Then I get the following exception:
return FileAttachment("athletes.json").json().then(athletes =>
^
TypeError: FileAttachment(...).json is not a function
at generateGraph (file:///.../argh.js:7:42)
athletes.json is in the same folder as this code.
I can’t find any examples of code like this not working online, yet I can’t seem to make it work!
Could somebody please tell me what I’m doing wrong?
Many thanks!