Promise study concluded (2)

Application of the Promise : task execution order, based on the content request retransmission request back

Scenario : Suppose you want to get NetEase cloud music of the song according to the comments below click on a song, which requires requesting a song of success callback, again requesting comments

First, a function to retrieve the data package
 
 
Call the function to retrieve the music id = 2
In obtaining a successful callback id = 2, then the method to get the corresponding comments url, then returned again to a transmission request Promise object, so then the method call chain

 

 

As a result, Promise chained calls to .then way, this time with a lot of Promise will be clean, otherwise it will deeply nested callback function.

 

 

Guess you like

Origin www.cnblogs.com/zxmonster/p/11895734.html