Created
March 1, 2022 05:21
-
-
Save XboxBedrock/221bab2d31b40ff9051ffb5eb51fe26e to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
const fetch = require("node-fetch"); | |
const chalk = require("chalk"); | |
const res = fetch("https://what-to-code.com/api/ideas/random").catch(err => { | |
console.log(chalk.red("An error occured")); | |
}); | |
res.then(res => res.json()).then(data => { | |
console.log(chalk.bold.green(data.title)); | |
console.log(chalk.yellow(data.description || "No description")); | |
console.log(chalk.green(`${data.likes} likes`)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment