Skip to content

Commit f9f3a4b

Browse files
authored
README: Fix variable name collision in examples. (#90)
The example snippets weren't valid. One would get a reference error when trying to make use of it. `ReferenceError: Cannot access 'zulip' before initialization`
1 parent 8aedbf6 commit f9f3a4b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ Javascript library to access the Zulip API
99
### With API Key
1010

1111
```js
12-
const zulip = require('zulip-js');
12+
const zulipInit = require('zulip-js');
1313
const config = {
1414
username: process.env.ZULIP_USERNAME,
1515
apiKey: process.env.ZULIP_API_KEY,
1616
realm: process.env.ZULIP_REALM,
1717
};
1818

1919
(async () => {
20-
const zulip = await zulip(config);
20+
const zulip = await zulipInit(config);
2121
// The zulip object now initialized with config
2222
console.log(await zulip.streams.subscriptions.retrieve());
2323
})();
2424
```
2525

2626
### With Username & Password
2727

28-
You will need to first retrieve the API key by calling `await zulip(config)`.
28+
You will need to first retrieve the API key by calling `await zulipInit(config)`.
2929

3030
```js
31-
const zulip = require('zulip-js');
31+
const zulipInit = require('zulip-js');
3232
const config = {
3333
username: process.env.ZULIP_USERNAME,
3434
password: process.env.ZULIP_PASSWORD,
@@ -37,7 +37,7 @@ const config = {
3737

3838
(async () => {
3939
// Fetch API Key
40-
const zulip = await zulip(config);
40+
const zulip = await zulipInit(config);
4141
// The zulip object now contains the API Key
4242
console.log(await zulip.streams.subscriptions.retrieve());
4343
})();
@@ -54,14 +54,14 @@ key=wlueAg7cQXqKpUgIaPP3dmF4vibZXal7
5454
site=http://localhost:9991
5555
```
5656

57-
Please remember to add this file to your `.gitignore`! Calling `await zulip({ zuliprc: 'zuliprc' })` will read this file.
57+
Please remember to add this file to your `.gitignore`! Calling `await zulipInit({ zuliprc: 'zuliprc' })` will read this file.
5858

5959
```js
60-
const zulip = require('zulip-js');
60+
const zulipInit = require('zulip-js');
6161
const path = require('path');
6262
const zuliprc = path.resolve(__dirname, 'zuliprc');
6363
(async () => {
64-
const zulip = await zulip({ zuliprc });
64+
const zulip = await zulipInit({ zuliprc });
6565
// The zulip object now contains the config from the zuliprc file
6666
console.log(await zulip.streams.subscriptions.retrieve());
6767
})();

0 commit comments

Comments
 (0)