0.8.0 • Published 2 years ago
lib-hn v0.8.0
Lib-HN
This project (Lib-HN
) is a lightweight package/library for interacting with the Hacker News API and uses the Axios library under the hood to handle the actual sending/receiving of requests.
Basic Usage
The following code block is a one way of using the library but there are more examples available in the ./examples
directory.
import { LibHN } from 'lib-hn'
const client = new LibHN({ baseUrl: 'url-goes-here', version: 'v0' })
async function main() {
try {
const topStoryIds = await client.getStories('top')
return topStoryIds
} catch (err) {
console.error('Error received when attempting to execute main() method...')
throw err
}
}
main()
.then(res => {
console.log(res)
console.log('Execution completed successfully.')
})
.catch(err => console.error(err))