This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

communicate-api
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

Communicate API

API to communicate frontend with backend. Communicate API is a wrapper over axios package with default request settings for AxiosInstance out of the box.

Use

The module provides access to the Communicate class, whose instance contains the session filed. This field has AxiosInstance with default or passed request settings. The session field supports all methods that axios instance supports.

Example

import Communicate from 'communicate-api';
const djangoSession = new Communicate();
djangoSession.session.get('/some/path');

Pass settings

When creating the instance of Communicate you can redefine or extend default settings via passing custom settings to Communicate constructor. Custom settings can contain all the same settings that axios supports. Axios request config.

Also the Communicate has extra settings.

V.1.0.*

Communicate extra settings

baseUrl

Package determines on what computer the application is running via NODE_ENV. In case if NODE_ENV equal production the app will use <sheme>://<domaine> as default baseURL. Otherwise by default baseURL is http://localhost:8000. If you need to define a different baseURL for developer machine or production you need to add the value to devUrl key or prodUrl key or both in the custom settings object.

Example

const customSettings = { devUrl: 'http//127.0.0.1:5000', ...axiosSettings };
const djangoSession = new Communicate(customSettings);

Default axios settings

{
    baseURL: (develop) '127.0.0.1:8000' | (production) <scheme>://<domain>
    xsrfCookieName: 'csrftoken',
    withCredentials: true,
    xsrfHeaderName: 'X-CSRFToken',
    timeout: 100000,
    headers: {
        'Content-Type': 'application/json'
    }
}

Package Sidebar

Install

npm i communicate-api

Weekly Downloads

1

Version

1.2.2

License

MIT

Unpacked Size

13.8 kB

Total Files

13

Last publish

Collaborators

  • j4ck_vvh173