mirror of https://github.com/zulip/zulip.git
js_examples: Migrate and test register_queue example.
This commit is contained in:
parent
4aec4cbfae
commit
5a4d31825c
|
@ -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}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue