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_stream_id example.

Kartik Srivastava2c5815edbbc4
diff --git a/templates/zerver/api/get-stream-id.md b/templates/zerver/api/get-stream-id.md
index e64ddfb96e8..c1970310c63 100644
--- a/templates/zerver/api/get-stream-id.md
+++ b/templates/zerver/api/get-stream-id.md
@@ -12,19 +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 the ID of a given stream
- client.streams.getStreamId('Denmark').then(console.log);
-});
-```
+
+{generate_code_example(javascript)|/get_stream_id:get|example}
{tab|curl}
diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js
index 1df5968c2fc..60dee1480e8 100644
--- a/zerver/openapi/javascript_examples.js
+++ b/zerver/openapi/javascript_examples.js
@@ -41,6 +41,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.delete_queue);
await generate_validation_data(client, examples.get_messages);
await generate_validation_data(client, examples.get_own_user);
+ await generate_validation_data(client, examples.get_stream_id);
console.log(JSON.stringify(response_data));
return;
@@ -150,4 +151,11 @@ add_example('get_own_user', '/users/me:get', 200, async (client) => {
// {code_example|end}
});
+add_example('get_stream_id', '/get_stream_id:get', 200, async (client) => {
+ // {code_example|start}
+ // Get the ID of a given stream
+ return await client.streams.getStreamId('Denmark');
+ // {code_example|end}
+});
+
main();