customer-js-sdk
Customer JS SDK main repo.
Last updated a day ago by sling-web .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install customer-js-sdk 
SYNC missed versions from official npm registry.

customer-js-sdk

The customer-js-sdk is a Front-End layer of abstraction for communicating with Back-End services.

Install

npm install --save customer-js-sdk

Import

import { v0 as sdk } from 'customer-js-sdk';

BaseUrl

  • Setting the baseUrl
sdk.baseUrl.set('http://custom.api/');

Headers

  • Setting a header
sdk.headers.append('Content-Type', 'application/json');
  • Retrieving all headers
sdk.headers.get();
  • Removing a header
sdk.headers.remove('Content-Type');

Usage Examples

  • GET request without parameters
sdk.merchants.partners.get();
  • GET request with URL parameter
sdk.merchants.addresses.get({
  urlParam: '123456789'
});
  • POST request with body
sdk.merchants.contacts.post({}, {
  body: '123456789'
});
  • POST request with URL parameter and body
sdk.merchants.contacts.post({
  urlParam: '123456789'
}, {
  body: '123456789'
});
  • Passing a custom baseUrl to overide the default in a specific request
sdk.merchants.partners.get('https://custom.api/');

sdk.merchants.addresses.get('https://custom.api/', {
  urlParam: '123456789'
});

sdk.merchants.contacts.post('https://custom.api/', {
  urlParam: '123456789'
}, {
  body: '123456789'
});

Using Middlewares

Middlewares run before and after every request in the same order that they were declared. Every middleware must call either proceed or quit in order to work.

sdk.middleware.use({
  beforeRequest({ proceed, quit }) {
    if (conditionMet) {
      proceed();
    } else {
      quit();
    }
  },
  afterRequest({ proceed }) {
    logSomething();
    proceed();
  }
});

sdk.middleware.use({
  async beforeRequest({ proceed }) {
    await doSomethingAsync();
    proceed();
  }
});

See more information on our Wiki page.

Current Tags

  • 1.50.3                                ...           latest (a day ago)

63 Versions

  • 1.50.3                                ...           a day ago
  • 1.50.2                                ...           a day ago
  • 1.50.1                                ...           a day ago
  • 1.50.0                                ...           a day ago
  • 1.49.1                                ...           10 days ago
  • 1.49.0                                ...           10 days ago
  • 1.48.0                                ...           20 days ago
  • 1.47.0                                ...           25 days ago
  • 1.46.1                                ...           25 days ago
  • 1.46.0                                ...           25 days ago
  • 1.45.0                                ...           a month ago
  • 1.44.1                                ...           a month ago
  • 1.44.0                                ...           a month ago
  • 1.43.0                                ...           a month ago
  • 1.42.0                                ...           a month ago
  • 1.41.0                                ...           2 months ago
  • 1.40.0                                ...           2 months ago
  • 1.39.0                                ...           3 months ago
  • 1.38.0                                ...           3 months ago
  • 1.37.0                                ...           3 months ago
  • 1.36.0                                ...           3 months ago
  • 1.35.0                                ...           3 months ago
  • 1.34.0                                ...           3 months ago
  • 1.33.0                                ...           3 months ago
  • 1.32.0                                ...           4 months ago
  • 1.31.0                                ...           4 months ago
  • 1.30.0                                ...           4 months ago
  • 1.29.1                                ...           4 months ago
  • 1.29.0                                ...           4 months ago
  • 1.28.0                                ...           5 months ago
  • 1.27.0                                ...           5 months ago
  • 1.26.0                                ...           5 months ago
  • 1.25.0                                ...           5 months ago
  • 1.24.0                                ...           6 months ago
  • 1.23.0                                ...           6 months ago
  • 1.22.0                                ...           6 months ago
  • 1.21.0                                ...           6 months ago
  • 1.20.1                                ...           6 months ago
  • 1.20.0                                ...           6 months ago
  • 1.19.0                                ...           6 months ago
  • 1.18.0                                ...           6 months ago
  • 1.17.0                                ...           7 months ago
  • 1.16.0                                ...           7 months ago
  • 1.15.0                                ...           7 months ago
  • 1.13.0                                ...           7 months ago
  • 1.12.0                                ...           7 months ago
  • 1.11.0                                ...           7 months ago
  • 1.10.0                                ...           8 months ago
  • 1.9.0                                ...           8 months ago
  • 1.8.0                                ...           9 months ago
  • 1.7.0                                ...           10 months ago
  • 1.6.0                                ...           10 months ago
  • 1.5.1                                ...           a year ago
  • 1.5.0                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 4
This Week 135
This Month 170
Last Day 72
Last Week 35
Last Month 227
Dependencies (4)

Copyright 2014 - 2016 © taobao.org |