Dataview query inside templaterjs returns dv is not defined

What I’m trying to do

I am trying to use a dataview query dv.tryQuery() inside a templater JavaScriptQuery, i.e.

<%*
let x = await dv.tryQuery("LIST FROM ''")
tR += `${x}`
%>

Unfortunately, the console returns
Template parsing error, aborting. dv is not defined

Things I have tried

I’ve already tested this in a Sandbox vault with only Templater and Dataview being installed.

There is this one related question in the forum but it does not apply to my case, since I’ve tested Sandbox vault.

What am I missing? Thank you!

1 Like

Try adding the following at the start of your templater js block:

const dv = this.app.plugins.plugins["dataview"].api
3 Likes

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