functiongetArticlesData(id,callback){// Simulate async operationsetTimeout(()=>{callback([{username:'user1'},{username:'user2'}]);// Dummy data},1000);}functiongetUserData(username,callback){// Simulate async operationsetTimeout(()=>{callback(username+'_name');// Dummy transformation},1000);}functiongetAddress(name,callback){// Simulate async operationsetTimeout(()=>{callback(name+'_address');// Dummy transformation},1000);}// Calling the functions in a callback hell mannergetArticlesData(20,(articles)=>{console.log("article lists",articles);// Assuming you want to process the first article in the listgetUserData(articles[0].username,(name)=>{console.log(name);getAddress(name,(item)=>{console.log(item);// This goes on and on...});});});
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)