junobuild / juno-js

JavaScript libraries for interfacing with Juno
MIT License
14 stars 1 forks source link

getAsset not exported? #171

Closed ByronBecker closed 1 month ago

ByronBecker commented 1 month ago

When trying to use the getAsset API I receive this error:

import {listAssets, getAsset, uploadBlob} from "@junobuild/core";
                    ^^^^^^^^
SyntaxError: The requested module '@junobuild/core' does not provide an export named 'getAsset'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12

However, the get_asset canister endpoint exists on my satellite (via the Candid UI).

peterpeterparker commented 1 month ago

I just updated the NodeJS basic example and added an assets sample containing a getAsset.

What version of the library are you using?

You can also try to use @junobuild/core-peer instead of @junobuild/core maybe?

The 'core' package includes agent-js within the library, whereas 'core-peer' relies on agent-js as peer dependencies. Depending on the environment, one may work better than the other. The ultimate goal is to use 'core' universally, but bundling agent-js is currently challenging unfortunately.