Get content of a note with dataviewjs?

I’m trying read the content of every note, so that I can filter data inside the notes:

let pages = dv.pages();

for (let page of pages) {
  const content = page.content;

  console.log(content);
...
}

When I tried logging the note in the console, I noticed there is no ‘content’ property on page variable. So where is this content stored and how can you retrieve it?

You need to do something like:

const content = await dv.io.load(page.file.path)

Thank you. I’m getting this error:

valuation Error: SyntaxError: await is only valid in async functions and the top level bodies of modules
    at DataviewInlineApi.eval (plugin:dataview:18370:21)
    at evalInContext (plugin:dataview:18371:7)
    at asyncEvalInContext (plugin:dataview:18378:16)
    at DataviewJSRenderer.render (plugin:dataview:18402:19)
    at DataviewRefreshableRenderer.maybeRefresh (plugin:dataview:17980:22)
    at e.tryTrigger (app://obsidian.md/app.js:1:1064472)
    at e.trigger (app://obsidian.md/app.js:1:1064405)
    at t.trigger (app://obsidian.md/app.js:1:1841754)
    at DataviewPlugin.eval (plugin:dataview:19399:76)
    at s (app://obsidian.md/app.js:1:709926)
    at l (app://obsidian.md/app.js:1:710032)
    at r (plugin:obsidian-kindle-plugin:333:35936)

What is that needs to be made async?

How do you trigger your code? dv.view()? Templater? Some other function?

It’s the surrounding level which needs the async, and most likely an await at the outer level.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.