js_examples: Migrate and test register_queue example.

This commit is contained in:
Kartik Srivastava 2020-06-22 02:29:39 +05:30 committed by Tim Abbott
parent 4aec4cbfae
commit 5a4d31825c
2 changed files with 13 additions and 16 deletions

View File

@ -55,23 +55,8 @@ potentially messy races, etc.
{tab|js} {tab|js}
More examples and documentation can be found [here](https://github.com/zulip/zulip-js). More examples and documentation can be found [here](https://github.com/zulip/zulip-js).
```js
const zulip = require('zulip-js');
// Pass the path to your zuliprc file here. {generate_code_example(javascript)|/register:post|example}
const config = {
zuliprc: 'zuliprc',
};
zulip(config).then((client) => {
// Register a queue
const params = {
event_types: ['message']
};
client.queues.register(params).then(console.log);
});
```
{tab|curl} {tab|curl}

View File

@ -45,6 +45,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.get_stream_topics); await generate_validation_data(client, examples.get_stream_topics);
await generate_validation_data(client, examples.get_subscriptions); await generate_validation_data(client, examples.get_subscriptions);
await generate_validation_data(client, examples.get_users); await generate_validation_data(client, examples.get_users);
await generate_validation_data(client, examples.register_queue);
console.log(JSON.stringify(response_data)); console.log(JSON.stringify(response_data));
return; return;
@ -188,4 +189,15 @@ add_example('get_users', '/users:get', 200, async (client) => {
return [result_1, result_2]; return [result_1, result_2];
}); });
add_example('register_queue', '/register:post', 200, async (client) => {
// {code_example|start}
// Register a queue
const params = {
event_types: ['message'],
};
return await client.queues.register(params);
// {code_example|end}
});
main(); main();