Skip to content

ES6 simplified class for consuming data from an external service

License

Notifications You must be signed in to change notification settings

Truemedia/data-bite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data bite

ES6 simplified class for consuming data from an external service (Either JSONAPI or GraphQL)

Includes several presets for getting up an running quickly with API consumption, including:

Installation

Make sure you have an .env file present in the directory of the root script with the following params (will use the defaults if not)

DATA_TYPE=jsonapi
DATA_HOST=domain
DATA_PORT=portNumber
DATA_PATH=path

NPM

    npm i --save data-bite

Yarn

    yarn add data-bite

Usage

  const Data = require('data-bite');
  let preset = 'fortune';
  let service = new Data(preset).service();

  let resource = 'resource-name';
  let opts = {};

  service.get(resource, opts).then( (res) => {
    console.log(res.data);
  }).catch( (err) => {
    // Handle error
  });

About

ES6 simplified class for consuming data from an external service

Resources

License

Stars

Watchers

Forks

Packages

No packages published