9.7.0 • Published 16 days ago

@mattermost/client v9.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

Mattermost Client

npm version

This package contains the JavaScript/TypeScript client for Mattermost. It's used by the Mattermost web app and related projects.

Installation

JavaScript

$ npm install @mattermost/client

TypeScript

$ npm install @mattermost/client @mattermost/types

Usage

To use the client, create an instance of Client4, set the server URL, and log in, and then you can start making requests.

import {Client4} from '@mattermost/client';

const client = new Client4();
client4.setUrl('https://mymattermostserver.example.com');

client4.login('username', 'password').then((user) => {
    // ...
});

If you already have a session token or a user access token, you can call Client4.setToken instead of logging in.

import {Client4} from '@mattermost/client';

const client = new Client4();
client4.setUrl('https://mymattermostserver.example.com');

client4.setToken('accesstoken');

If needed, methods exist to set other headers such as the User-Agent (Client4.setUserAgent), the CSRF token (Client4.setCSRF), or any extra headers you wish to include (Client4.setHeader).

Methods of Client4 which make requests to the server return a Promise which does the following:

  • On success, the promise resolves to a ClientResponse<T> object which contains the the Response (response), a Map of headers (headers), and the data sent from the server (data).
  • On an error, the promise rejects with a ClientError which contains the error message and the URL being requested. If the error happened on the server, the status code and an error ID (server_error_id) are included.
let user;
try {
    user = (await client.getUser('userid')).data;
} catch (e) {
    console.error(`An error occurred when making a request to ${e.url}: ${e.message}`);
}

Compilation and Packaging

As a member of Mattermost with write access to our NPM organization, you can build and publish this package by running the following commands:

npm run build --workspace=platform/client
npm publish --workspace=platform/client

Make sure to increment the version number in package.json first! You can add -0, -1, etc for pre-release versions.

9.7.0

16 days ago

9.7.0-0

1 month ago

9.6.0

2 months ago

9.5.0

2 months ago

9.4.0

3 months ago

9.3.0

4 months ago

8.0.0

8 months ago

8.1.1

8 months ago

9.2.0

6 months ago

9.1.0

6 months ago

9.0.0

8 months ago

7.10.0

1 year ago

7.8.0

1 year ago

7.9.0

1 year ago

7.7.0

1 year ago

7.4.0

2 years ago

7.3.0

2 years ago

7.0.0

2 years ago

7.1.0

2 years ago

6.7.0-0

2 years ago