api/private-message: Recommend using zuliprc.

Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
This commit is contained in:
Eeshan Garg 2018-01-13 18:14:34 -03:30 committed by showell
parent e36d61f216
commit e781a57ca2
1 changed files with 10 additions and 9 deletions

View File

@ -67,19 +67,20 @@ More examples and documentation can be found [here](https://github.com/zulip/zul
```js
const zulip = require('zulip-js');
// Download zuliprc-dev from your dev server
const config = {
username: 'othello-bot@example.com',
apiKey: 'a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5',
realm: '{{ api_url }}'
zuliprc: 'zuliprc-dev',
};
const client = zulip(config);
zulip(config).then((client) => {
// Send a private message
const params = {
to: 'hamlet@example.com',
type: 'private',
content: 'I come not, friends, to steal away your hearts.',
}
// Send a private message
client.messages.send({
to: 'hamlet@example.com',
type: 'private',
content: 'I come not, friends, to steal away your hearts.'
client.messages.send(params).then(console.log);
});
```