Created
December 3, 2021 13:11
-
-
Save vojtaholik/4430deecee2b637b2fd3f09cf90dca22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Menu: Book Search | |
// Description: Use Open Library API to search for books | |
// Author: John Lindquist | |
// Twitter: @johnlindquist | |
let query = await arg('Search for a book title:') | |
//This API can be a little slow. Wait a couple seconds | |
let response = await get(`http://openlibrary.org/search.json?q=${query}`) | |
let transform = ({title, author_name}) => | |
`* "${title}" - ${author_name?.length && author_name[0]}` | |
let markdown = response.data.docs.map(transform).join('\n') | |
inspect(markdown, 'md') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment