1.0.1 • Published 2 years ago
nikhil-joshi-lotr-sdk-2 v1.0.1
Lord of the Rings SDK
NPM Package link
Installation:
Using npm:
npm i nikhil-joshi-lotr-sdk-2Usage:
In Node.js:
// 'require' Syntax
// Get the default api function export to initialize the lib
const api = require('nikhil-joshi-lotr-sdk-2')
// Initialize the lib with the auth token
api('authorization-token')
const {movies, quotes} = require('nikhil-joshi-lotr-sdk-2')
// Example api call
movies.getAll().then(res => {
console.log(res.data)
})
quotes.getAll().then(res => {
console.log(res.data)
}) // 'import' syntax
import api, {movies, quotes} from 'nikhil-joshi-lotr-sdk-2'
// Initialize the lib with the auth token
api('authorization-token')
movies.getAll().then(res => {
console.log(res.data)
})
quotes.getAll().then(res => {
console.log(res.data)
})Optional Params:
- Some of the methods take an optional params object argument. The details of the supported keys are as follows:
limit- Total items to return. Defaults to10page- The page number of the datasetoffset- The data offsetsortKey- The field in the data set to sort on.sortDirection-ascordesc. Defaults toascmatch: Object with options to match or unmatch on a specific keykey- The field in the datasetvalue- The value to matchnegate- Iftrue, returns allnotmatching values
includekey- The field in the datasetvalue- The values to include (comma-separated)
excludekey- The field in the datasetvalue- The values to exclude (comma-separated)
existsKey- The field name in the data set. If specified, only the items that contains the specified key will be returned.doesnotExistKey- The field name in the data set. If specified, only the items that does not contain the specified key will be returned.regexkey- The field in the datasetvalue- The regex for the fieldnegate- Iftrue, returns allnotmatching the regex
comparekey- The field in the dataset for comparisonvalue- The value for the comparisonoperator- The comparison operator. See all possible values below.gt- corresponds to '>',lt- corresponds to '<',eq- corresponds to '=',geq- corresponds to '>=',leq- corresponds to '<=',
Tests:
Running the unit tests:
npm run test