Skip to content

dtone/dtone-dvs-api-node-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Easily integrate DT One's DVS API (https://dvs-api-doc.dtone.com/) to your NodeJs application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •