1.1.1 • Published 10 months ago
hltbjs v1.1.1
How long to beat API wrapper
How long to beat is a web-resource where users can find out how long it will take to beat a game.
This package is simple wrapper around API which allows to fetch data from the website.
Installation
- npm
npm install hltbjs
- yarn
yarn add hltbjs
Usage
Search method
It takes two arguments:
searchTerm
- term used for search;SearchOptions
- object where options for search are described. Currently it consists ofpageSize
option only.
import { search } from 'hltbjs';
// Using promise
search('Call of Duty', { pageSize: 10 }).then(result => console.log(result));
// Using async/await
const foo = async () => {
const result = await search('Call of Duty', { pageSize: 10 }).then(result => console.log(result));
console.log(result);
};
foo();
- Response example:
[
{
id: 1464,
name: 'Call of Duty',
imageURL: 'https://howlongtobeat.com/games/Codbox.jpg',
durationMain: 7,
durationMainExtra: 9,
durationCompletionist: 9.5,
},
{
id: 27127;
name: 'Call of Duty: Black Ops III',
imageURL: 'https://howlongtobeat.com/games/COD_Black_Ops_3.jpg',
durationMain: 9,
durationMainExtra: 14.5,
durationCompletionist: 82.5,
},
...
]