Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

js_examples: Migrate and test get_streams example.

Kartik Srivastavab32e851458d5
diff --git a/templates/zerver/api/get-streams.md b/templates/zerver/api/get-streams.md
index 698479ab6f1..43cb859df0f 100644
--- a/templates/zerver/api/get-streams.md
+++ b/templates/zerver/api/get-streams.md
@@ -12,20 +12,8 @@
{tab|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.
-const config = {
- zuliprc: 'zuliprc',
-};
-
-zulip(config).then((client) => {
- // Get all streams that the user has access to
- client.streams.retrieve().then(console.log);
-});
-
-```
+{generate_code_example(python)|/streams:get|example}
{tab|curl}
diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js
index a1d02292b75..6c0d1cf4431 100644
--- a/zerver/openapi/javascript_examples.js
+++ b/zerver/openapi/javascript_examples.js
@@ -53,6 +53,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.update_message_flags);
await generate_validation_data(client, examples.update_message);
await generate_validation_data(client, examples.get_events);
+ await generate_validation_data(client, examples.get_streams);
console.log(JSON.stringify(response_data));
return;
@@ -353,4 +354,11 @@ add_example('get_events', '/events:get', 200, async (client) => {
// {code_example|end}
});
+add_example('get_streams', '/streams:get', 200, async (client) => {
+ // {code_example|start}
+ // Get all streams that the user has access to
+ return await client.streams.retrieve();
+ // {code_example|end}
+});
+
main();