How to call a canister method from javascript?

If I look at the ‘hello’ application, the call to a canister method is as follows:

const greeting = await hello.greet(name);

The ‘hello’ canister object is imported as follows:

import { hello } from “…/…/declarations/hello”;

The declarations folder is not present at first but is presumably created as part of the build process. I am working on a Svelte app and I don’t know of a way to build this declarations folder. I suspect I am missing a dependency that takes care of this for me. How can I proceed?

You can get them after building the “greeting” canister. It’s under .dfx folder

1 Like

You get the “src/declarations” generated by running dfx generate. Documentation resides here

1 Like