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:
parent
fedfb494ee
commit
d0f67c9f8b
1 changed files with 9 additions and 3 deletions
12
README.md
12
README.md
|
|
@ -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();
|
||||
```
|
||||
|
||||
---
|
||||
|
|
|
|||
Loading…
Reference in a new issue