Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
Fix Node.js example
Browse files Browse the repository at this point in the history
  • Loading branch information
rojvv committed Sep 4, 2023
1 parent 7429fb2 commit ce2e7e3
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/hello-world/node-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ to start since we don’t have a persistency layer for the sake of staying simpl
```ts
const client = new Client();

console.log("Starting client...");
await client.connect();
console.log("Client started.");
async function main() {
console.log("Starting client...");
await client.connect();
console.log("Client started.");
}

main();
```

The above code initializes a client with the default parameters and no API
Expand Down Expand Up @@ -83,14 +87,18 @@ const { Client, functions } = require("@mtkruto/node");

const client = new Client();

console.log("Starting client...");
await client.connect();
console.log("Client started.");
async function main() {
console.log("Starting client...");
await client.connect();
console.log("Client started.");

const before = Date.now();
await client.invoke(new functions.Ping({ pingId: 1n }));
const diff = Math.floor(Date.now() - before);
console.log("Ping took", `${diff}ms.`);
const before = Date.now();
await client.invoke(new functions.Ping({ pingId: 1n }));
const diff = Math.floor(Date.now() - before);
console.log("Ping took", `${diff}ms.`);
}

main();
```

Use the following command to run it:
Expand Down

0 comments on commit ce2e7e3

Please sign in to comment.