api/create-user: Add JavaScript example.

This commit is contained in:
Eeshan Garg 2018-01-13 19:10:45 -03:30 committed by showell
parent 0e778e152d
commit df00e6a45f
1 changed files with 24 additions and 0 deletions

View File

@ -15,6 +15,7 @@ Create a new user in a realm.
<ul class="nav">
<li data-language="curl">curl</li>
<li data-language="python">Python</li>
<li data-language="javascript">JavaScript</li>
</ul>
<div class="blocks">
@ -53,6 +54,29 @@ print(client.create_user({
</div>
<div data-language="javascript" markdown="1">
More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
```js
const zulip = require('zulip-js');
// You need a zuliprc-admin with administrator credentials
const config = {
zuliprc: 'zuliprc-admin',
};
zulip(config).then((client) => {
// Create a user
const params = {
email: 'newbie@zulip.com',
password: 'temp',
full_name: 'New User',
short_name: 'newbie'
};
client.users.create(params).then(console.log);
});
```
</div>
</div>
</div>