@dtone/dvs

1.2.0 • Public • Published

dvs-api

Documentation

The documentation for DVS API can be found here

Install

> npm i @dtone/dvs

Sample usage

Initialization

const { DVS } = require('@dtone/dvs');

const dvs = new DVS({
  apiKey: 'your-api-key-here',
  apiSecret: 'your-api-secret-here'
});

Fetching all the pages of an API

(async function () {
  // initial pageing params
  const params = { page: 1, perPage: 10 },

    // initialize the async iterable object
    it = dvs.discovery.countries.get({ params });

  try {
    for await (let data of it) {
      console.log(JSON.stringify(data));
    }
  } catch (err) {
    console.log(JSON.stringify(err));
  }
})();

Error handling

const { DVSAPIError } = require(@dtone/dvs');

try {
  const result = await dvs.discovery.countries.getByCountryIsoCode({ countryIsoCode: 'SGP' });
} catch (err) {
  if (err instanceof DVSAPIError) {
    console.log(err.status, err.statusText, err.data);
  }

  // other error like timeouts, network issues, wrong params etc
}

API Documentation

See here

/@dtone/dvs/

    Package Sidebar

    Install

    npm i @dtone/dvs

    Weekly Downloads

    65

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    25.3 kB

    Total Files

    20

    Last publish

    Collaborators

    • afmsayem
    • dtone-open-source
    • mohdhallal
    • josnidhin