sbx-client-request

0.2.11 • Public • Published

SBX Request

sbx i --save sbx-request
import Request from 'sbx-request';

const getServerUrl = () => {
  let server = APP_CONFIG.connection.REST;
  return server.protocol + '://' + server.host + ':' + server.port;
};

const request = new Request({
  url: getServerUrl(), // Url to backend server,
  needAuthorization: true, // If true, check and save Authorization key, default - true,
  headers: {..yourHeaders}, // If you need to send some custome headers, default - { 'Content-Type': 'application/json' }
  commonData: {
    apiVersion: 2
  } //some common data in any request
})

export default request;
import request from 'path';
request.post({
  url: '/trade', // relative part of url
  data: {...yourObject}, // data
  needAuthorization: false, // If false Auth token will not send to server, priority over property in class instance creation,
  async: true, // default - true
})

// request methods:
// post, put, get, delete, patch
// logout - clear Auth token from both localStorage and Cookie

Readme

Keywords

none

Package Sidebar

Install

npm i sbx-client-request

Weekly Downloads

52

Version

0.2.11

License

ISC

Unpacked Size

10.9 kB

Total Files

5

Last publish

Collaborators

  • v.sobix