Need feed back on how to properly code asynchronously.(Random Quote Generator)

I took a somewhat circuitous route on this challenge because I decided to use the wikiquotes API to pull quotes. Because the API isn’t the most friendly thing and the formatting is less than uniform, it took a bit of work to get what I wanted out of the code. I had to fetch random letters, then random names, then finally random quotes.

Although I needed one value to start the next request, I can only fetch them asynchronously. I had to write them as named functions and nest them. It resulted in a lot of nesting and anonymous functions calls and looks generally kind of messy. I’ve yet to style the interface because most of the time was sunk into figuring out how to use the wiki API.

I’ve little exposure to asynchronous functions, so I’m unsure if I’m doing this the right way. I consulted some articles and books, but I’d like some feedback on the code and if there are better ways to do this.

Random Numbers Generator

Have you tried these?







I have watched the video series and I think I will switch over to using Promises. I considered using JQuery deferred objects for a bit but decided to plow through with call backs.

I think the core of my problem is that I needed the functions to act sequentially. I needed the starting letter to pick a name, and I needed a name to pick a quote and I needed the quote to put on the page. One can’t start without the other, thus the nested callbacks. Wiki API isn’t nice enough to let me just simply randomly query a page in the people category with just 1 request.

On a conceptual level, I think I understand the nature asynchronous functions and callbacks, but I can’t help but think I’m jumping through hoops to do something straight forward