doc: improve Node.js client example (#320)

Fix doc to increase the developer experience...

- if the code is intended to be a CommonJS by using `require` then you have to wrap `await` calls in an async function
- calling `client.recall` with using the results
This commit is contained in:
Van Vuong Ngo 2026-02-07 10:02:41 +01:00 committed by GitHub
parent fedfb494ee
commit d0f67c9f8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,10 +116,16 @@ npm install @vectorize-io/hindsight-client
```javascript
const { HindsightClient } = require('@vectorize-io/hindsight-client');
const client = new HindsightClient({ baseUrl: 'http://localhost:8888' });
const example = async () => {
const client = new HindsightClient({ baseUrl: 'http://localhost:8888' });
await client.retain('my-bank', 'Alice loves hiking in Yosemite');
await client.recall('my-bank', 'What does Alice like?');
await client.retain('my-bank', 'Alice loves hiking in Yosemite');
const results = await client.recall('my-bank', 'What does Alice like?');
console.log(results);
}
example();
```
---