// 'require' Syntax// Get the default api function export to initialize the libconstapi=require('nikhil-joshi-lotr-sdk-2')// Initialize the lib with the auth tokenapi('authorization-token')const{movies, quotes}=require('nikhil-joshi-lotr-sdk-2')// Example api callmovies.getAll().then(res=>{console.log(res.data)})quotes.getAll().then(res=>{console.log(res.data)})
// 'import' syntaximportapi,{movies,quotes}from'nikhil-joshi-lotr-sdk-2'// Initialize the lib with the auth tokenapi('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 to 10
page - The page number of the dataset
offset - The data offset
sortKey - The field in the data set to sort on.
sortDirection- asc or desc. Defaults to asc
match: Object with options to match or unmatch on a specific key
key - The field in the dataset
value - The value to match
negate - If true, returns all not matching values
include
key - The field in the dataset
value - The values to include (comma-separated)
exclude
key - The field in the dataset
value - 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.
regex
key - The field in the dataset
value - The regex for the field
negate - If true, returns all not matching the regex
compare
key - The field in the dataset for comparison
value - The value for the comparison
operator - The comparison operator. See all possible values below.