sbx-client-request
v0.2.11
Published
sbx-client-request
Downloads
330
Readme
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