UNPKG

@meisens1/lotr-sdk

Version:
57 lines (35 loc) 1.59 kB
A simple Javascript SDK for the [One API](https://the-one-api.dev/). ## Installation ```sh 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](https://the-one-api.dev/documentation) 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. ```js 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 }); ```