Skip to content

Commit

Permalink
runtime error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gagan-bhullar-tech authored Mar 7, 2025
1 parent 226c823 commit 5e3defc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions files/en-us/webassembly/guides/rust_to_wasm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ In your `package.json`, you can add `build` and `serve` scripts that will run we
Next, create a file named `index.js`, and give it these contents:

```js
import * as wasm from "hello-wasm";
import init, { greet } from 'hello-wasm';

wasm.greet("WebAssembly with npm");
init().then(() => {
greet('WebAssembly with npm');
});
```

This imports the module from the `node_modules` folder and calls the `greet` function, passing `"WebAssembly with npm"` as a string. Note how there's nothing special here, yet we're calling into Rust code. As far as the JavaScript code can tell, this is just a normal module.
Expand Down

0 comments on commit 5e3defc

Please # to comment.