Created
May 10, 2021 09:12
-
-
Save chrisvoo/4eef37cd6bfecf7654f826dd2f970039 to your computer and use it in GitHub Desktop.
Retrieving artist's top albums
This file contains 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
/* 57034 results for 1141 pages! */ | |
import dotenv from 'dotenv'; | |
import LastFM from 'last-fm'; | |
import { envSchema } from './utils'; | |
import { showResult } from './utils/terminal'; | |
const result = dotenv.config(); | |
if (result.error) { | |
console.error(result.error.message); | |
process.exit(1); | |
} | |
const { error } = envSchema.validate(result.parsed); | |
if (error) { | |
console.error(error.message); | |
process.exit(1); | |
} | |
(async () => { | |
const lastfm = new LastFM(process.env.API_KEY, { | |
userAgent: 'DiscoCLI/0.0.1 (https://github.com/chrisvoo/discocli)', | |
}); | |
lastfm.artistTopAlbums({ name: 'blink182' }, (err: any, data: any) => { | |
if (err) { | |
console.error(err); | |
process.exit(1); | |
} | |
showResult(data); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment