js_examples: Migrate and test get_stream_topics example.

This commit is contained in:
Kartik Srivastava 2020-06-22 02:02:42 +05:30 committed by Tim Abbott
parent 2c5815edbb
commit cc7671e602
2 changed files with 9 additions and 13 deletions

View File

@ -12,20 +12,8 @@
{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)|/users/me/{stream_id}/topics:get|example}
const config = {
zuliprc: 'zuliprc',
};
zulip(config).then((client) => {
// Get all the topics in stream with ID 1
return client.streams.topics.retrieve({ stream_id: 1 });
}).then(console.log);
```
{tab|curl} {tab|curl}

View File

@ -42,6 +42,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.get_messages); await generate_validation_data(client, examples.get_messages);
await generate_validation_data(client, examples.get_own_user); await generate_validation_data(client, examples.get_own_user);
await generate_validation_data(client, examples.get_stream_id); await generate_validation_data(client, examples.get_stream_id);
await generate_validation_data(client, examples.get_stream_topics);
console.log(JSON.stringify(response_data)); console.log(JSON.stringify(response_data));
return; return;
@ -158,4 +159,11 @@ add_example('get_stream_id', '/get_stream_id:get', 200, async (client) => {
// {code_example|end} // {code_example|end}
}); });
add_example('get_stream_topics', '/users/me/{stream_id}/topics:get', 200, async (client) => {
// {code_example|start}
// Get all the topics in stream with ID 1
return client.streams.topics.retrieve({ stream_id: 1 });
// {code_example|end}
});
main(); main();