mirror of https://github.com/zulip/zulip.git
js-api: Migrate and test create-user example.
This commit is contained in:
parent
61f6a6e9bb
commit
203b722624
|
@ -14,25 +14,8 @@
|
|||
{tab|js}
|
||||
|
||||
More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
|
||||
```js
|
||||
const zulip = require('zulip-js');
|
||||
|
||||
// The user for this zuliprc file must be an organization administrator.
|
||||
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);
|
||||
});
|
||||
```
|
||||
{generate_code_example(javascript)|/users:post|example(admin_config=True)}
|
||||
|
||||
{tab|curl}
|
||||
|
||||
|
|
|
@ -58,8 +58,21 @@ const ExamplesHandler = function () {
|
|||
};
|
||||
};
|
||||
|
||||
const {main} = ExamplesHandler();
|
||||
const {main, add_example} = ExamplesHandler();
|
||||
|
||||
// Declare all the examples below.
|
||||
|
||||
add_example('create_user', '/users:post', 200, async (client) => {
|
||||
// {code_example|start}
|
||||
const params = {
|
||||
email: 'newbie@zulip.com',
|
||||
password: 'temp',
|
||||
full_name: 'New User',
|
||||
short_name: 'newbie',
|
||||
};
|
||||
|
||||
return await client.users.create(params);
|
||||
// {code_example|end}
|
||||
});
|
||||
|
||||
main();
|
||||
|
|
Loading…
Reference in New Issue