How to use api in dataviewjs?

I try

import { Octokit } from ""
const octokit = new Octokit({ auth: 'ghp_token })
await octokit.request('GET /repos/QuaCau-TheSphere/Nhap-mon-Obsidian-cho-quan-ly-du-an/traffic/clones', { owner: 'ooker777', repo: 'Nhap-mon-Obsidian-cho-quan-ly-du-an' })

But it returns:

Evaluation Error: SyntaxError: Cannot use import statement outside a module
    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 DataviewJSRenderer.onload (plugin:dataview:17986:14)
    at DataviewJSRenderer.e.load (app://
    at DataviewApi.executeJs (plugin:dataview:18921:18)
    at DataviewPlugin.dataviewjs (plugin:dataview:19423:18)
    at eval (plugin:dataview:19344:124)
    at app://

Have you tried “custom views” to import packages? I do not know if it is possible or not.

See: Codeblock Reference - Dataview

You seem to have an import issue, and according to the link below you stod try using a <script> section in the html (or markdown for us) for the import.

I’m not sure if that’ll work, but it would be closer to the recommended way to import the module. I’m also not sure whether there are policies in obsidian which would be an issue with such an import.

Using dv.view() in this case, wouldn’t change anything, just move the issue to another place. I don’t think it will provide the necessary module context which is asked for.

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