Skip to content

Instantly share code, notes, and snippets.

@XboxBedrock
Created March 1, 2022 05:21
Show Gist options
  • Save XboxBedrock/221bab2d31b40ff9051ffb5eb51fe26e to your computer and use it in GitHub Desktop.
Save XboxBedrock/221bab2d31b40ff9051ffb5eb51fe26e to your computer and use it in GitHub Desktop.
#!/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