Execute Tasks in the Loop

Execute Tasks In the Loop Using Async.each Now I am going to show you how to execute asynchronous Tasks In the Loop by using async.each const Client = require(‘node-rest-client’).Client; const restClientService = new Client(); restClientService.registerMethod(‘getPosts’, ‘http://jsonplaceholder.typicode.com/users/1/posts’, ‘GET’); restClientService.registerMethod(‘getAlbums’, ‘http://jsonplaceholder.typicode.com/users/1/albums’, ‘GET’); restClientService.registerMethod(‘getPhotos’, ‘http://jsonplaceholder.typicode.com/albums/1/photos’, ‘GET’); export default restClientService;   function loopDemo(req, res, next) { let users = […]

Continue reading >

Execute Asynchronous Tasks in Series

What is Callback A callback is an asynchronous equivalent for a function. A callback function is called at the completion of a given task. function login(callback) { //do some operation callback(‘You have successfully LoggedIn’); } login(function(result) { console.log(result); });   I have created a login function. This login function is accepting one argument which is […]

Continue reading >