js_examples: Migrate and test render_message example.

This commit is contained in:
Kartik Srivastava 2020-06-22 02:48:59 +05:30 committed by Tim Abbott
parent 5a4d31825c
commit a1f6540cec
2 changed files with 13 additions and 16 deletions

View File

@ -12,23 +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) => {
// Render a message
const params = {
content: '**foo**',
};
client.messages.render(params).then(console.log);
});
```
{generate_code_example(javascript)|/messages/render:post|example}
{tab|curl}

View File

@ -46,6 +46,7 @@ const ExamplesHandler = function () {
await generate_validation_data(client, examples.get_subscriptions);
await generate_validation_data(client, examples.get_users);
await generate_validation_data(client, examples.register_queue);
await generate_validation_data(client, examples.render_message);
console.log(JSON.stringify(response_data));
return;
@ -200,4 +201,15 @@ add_example('register_queue', '/register:post', 200, async (client) => {
// {code_example|end}
});
add_example('render_message', '/messages/render:post', 200, async (client) => {
// {code_example|start}
// Render a message
const params = {
content: '**foo**',
};
return await client.messages.render(params);
// {code_example|end}
});
main();