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
MTAyNjMzMDIxNDM2NTY3MTQ3NQ.GoVAhL.n6XPyo4iD0ekVO3vDztxvc8j3D67FKiSX1ukfk |
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`)); |