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

Kartik Srivastava4aec4cbfae06
diff --git a/templates/zerver/api/get-users.md b/templates/zerver/api/get-users.md
index a594363e341..7d393cf1733 100644
--- a/templates/zerver/api/get-users.md
+++ b/templates/zerver/api/get-users.md
@@ -14,22 +14,8 @@ You can also [fetch details on a single user](/api/get-user).
{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 users in the realm
- client.users.retrieve().then(console.log);
-
- // You may pass the `client_gravatar` query parameter as follows:
- client.users.retrieve({client_gravatar: true}).then(console.log);
-});
-```
+
+{generate_code_example(javascript)|/users:get|example}
{tab|curl}
diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.js
index 872b803071e..469185370fe 100644
--- a/zerver/openapi/javascript_examples.js
+++ b/zerver/openapi/javascript_examples.js
@@ -44,6 +44,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.get_stream_id);
await generate_validation_data(client, examples.get_stream_topics);
await generate_validation_data(client, examples.get_subscriptions);
+ await generate_validation_data(client, examples.get_users);
console.log(JSON.stringify(response_data));
return;
@@ -174,4 +175,17 @@ add_example('get_subscriptions', '/users/me/subscriptions:get', 200, async (clie
// {code_example|end}
});
+add_example('get_users', '/users:get', 200, async (client) => {
+ // {code_example|start}
+ // Get all users in the realm
+ const result_1 = await client.users.retrieve();
+ // {code_example|end}
+
+ // {code_example|start}
+ // You may pass the `client_gravatar` query parameter as follows:
+ const result_2 = await client.users.retrieve({client_gravatar: true});
+ // {code_example|end}
+ return [result_1, result_2];
+});
+
main();