Base class for Payrex JS SDK. Don't use this repo directly, you should use payrex/js-sdk-node instead.
npm install --save payrex-js-sdk-base
const PayrexSdkBase = require('payrex-js-sdk-base');
const options = {/* ... options ... */};
const sdkBase = new PayrexSdkBase(options);
Option | Type | Usage | Description |
---|---|---|---|
credentials | string | optional | API secret key |
baseUrl | string | optional | API base url (default "http://localhost:3000/") |
fetch | function | required | Fetch function |
Headers | function | required | Fetch Headers |
Url | object | required | Url class |
Make HTTP-GET request to API.
Param | Type | Description |
---|---|---|
path | string | Path (ex. "/users" or "/users/1") |
options | object | Options |
options.queryParams | object | Additional query params to merge |
sdkBase
.get('/users?status=ACTIVE')
.then(response => { /* ... */})
.catch(err => {/* Process error */})
Make HTTP-POST request to API.
Param | Type | Description |
---|---|---|
path | string | Path (ex. "/users" or "/users/1") |
body | object | Body data |
options | object | Options |
options.queryParams | object | Additional query params to merge |
sdkBase
.post('/users', {
name: 'John Doe',
status: 'ACTIVE'
})
.then(response => { /* ... */})
.catch(err => {/* Process error */})
Make HTTP-PUT request to API.
Param | Type | Description |
---|---|---|
path | string | Path (ex. "/users" or "/users/1") |
body | object | Body data |
options | object | Options |
options.queryParams | object | Additional query params to merge |
sdkBase
.put('/users', {
name: 'Johnny Doe'
})
.then(response => { /* ... */})
.catch(err => {/* Process error */})
Make HTTP-DELETE request to API.
Param | Type | Description |
---|---|---|
path | string | Path (ex. "/users" or "/users/1") |
options | object | Options |
options.queryParams | object | Additional query params to merge |
sdkBase
.remove('/users/1')
.then(response => { /* ... */})
.catch(err => {/* Process error */})