Skip to content

Commit

Permalink
feat(example): prettier example log
Browse files Browse the repository at this point in the history
  • Loading branch information
AtoraSuunva committed Jul 13, 2022
1 parent 3a96355 commit a4c7728
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion example.js
Expand Up @@ -11,6 +11,19 @@ const searchUrl = Booru.forSite(site).getSearchUrl({ tags, limit: 1 })

console.log(`Searching with url: ${searchUrl}`)

function formatPost(post) {
return ({
id: post.id,
postView: post.postView,
fileUrl: post.fileUrl,
score: post.score,
rating: post.rating,
source: post.source,
createdAt: post.createdAt,
tags: post.tags.slice(0, 5),
})
}

// Search with promises
Booru.search(site, tags, { limit: 1, random: false })
.then((posts) => {
Expand All @@ -20,7 +33,7 @@ Booru.search(site, tags, { limit: 1, random: false })

console.log(`Found ${posts.length} image${posts.length === 1 ? '' : 's'}.`)
for (let post of posts) {
console.log(post.fileUrl)
console.log(formatPost(post))
}
})
.catch((err) => {
Expand Down

0 comments on commit a4c7728

Please sign in to comment.