Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A short example of callback hell.
getCat((data) => {
const catEmbed = new RichEmbed({ title: 'Meow' })
catEmbed.setImage(data.file);
message.channel.send("Nyaa ~ :cat: ", { embed: catEmbed })
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
/* ES5 Function */
getCat(function (data) {
/* Cat data 2 operations... */
getCat((data) => {
/* Cat data 3 operations... */
getCat((data) => {
/* Cat data 4 operations...
* Okay, too many callbacks now.
* Oh look a triangle.
*/
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment