1.0.1 • Published 10 months ago

@meisens1/lotr-sdk v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

A simple Javascript SDK for the One API.

Installation

npm i @meisens1/lotr-sdk

Authentication

To use the features of the LOTR SDK Client, you will need to provide an accessToken. To aquire an access token visit the one api website (https://the-one-api.dev/sign-up).

For use with the web API the baseUrl and accessToken are stored in the /src/config.js file for easy changing.

Quick Start

Run the client using the terminal type node client-test.js

Usage

The SDK models the One API and each property from the SDK models matches a section in the API documentation.

Examples

WEB API:

To list all movies:

navigate to the proper route localhost:3000/movies

Pagination has been implemented with page and limit options, defaulted to page = 1, limit = 100

http://localhost:3000/movie?page=2&limit=2

Additionally to use the SDK in code, refer to the controllers' methods for each type of model you expect back. For the purpose of this exercise, only moviesController and quoteController have been built so far as per the challenge.

import LOTR from '@meisens1/lotr-sdk';

const client = new LOTR('<ACCESS_TOKEN>'); // accessToken

//get the first page of 2 movies
client.listMovies({ page: 1, limit: 2 })
    .then((movies) => {
        console.log('Movies:', movies);
        // Handle the movie data here
    })
    .catch((error) => {
        console.error('Error:', error);
        // Handle the error here
    });
1.0.1

10 months ago

1.0.0

10 months ago