Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
js_examples: Migrate and test get_messages example.
Kartik Srivastava4615519d77ad
diff --git a/templates/zerver/api/get-messages.md b/templates/zerver/api/get-messages.mdindex c2f66dee2a7..fc64b1a38d9 100644--- a/templates/zerver/api/get-messages.md+++ b/templates/zerver/api/get-messages.md@@ -12,27 +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) => {- const readParams = {- stream,- type: 'stream',- anchor: res.id,- num_before: 1,- num_after: 1,- };-- // Fetch messages anchored around id (1 before, 1 after)- return client.messages.retrieve(readParams);-}).then(console.log);-```++{generate_code_example(javascript)|/messages:get|example}{tab|curl}diff --git a/zerver/openapi/javascript_examples.js b/zerver/openapi/javascript_examples.jsindex f02adeb5f14..50765425860 100644--- a/zerver/openapi/javascript_examples.js+++ b/zerver/openapi/javascript_examples.js@@ -39,6 +39,7 @@ const ExamplesHandler = function () {await generate_validation_data(client, examples.create_user);await generate_validation_data(client, examples.get_custom_emoji);await generate_validation_data(client, examples.delete_queue);+ await generate_validation_data(client, examples.get_messages);console.log(JSON.stringify(response_data));return;@@ -125,4 +126,19 @@ add_example('delete_queue', '/events:delete', 200, async (client) => {// {code_example|end}});+add_example('get_messages', '/messages:get', 200, async (client) => {+ // {code_example|start}+ const readParams = {+ anchor: 'newest',+ num_before: 100,+ num_after: 0,+ narrow: [{operator: 'sender', operand: '[email protected]'},+ {operator: 'stream', operand: 'Verona'}],+ };++ // Get the 100 last messages sent by "[email protected]" to the stream "Verona"+ return await client.messages.retrieve(readParams);+ // {code_example|end}+});+main();