All posts in "Node.js"
0 Shares

Execute Tasks in the Loop

October 14, 2017

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 = […]

0 Shares

Node.js : Execute Tasks In Parallel

October 11, 2017

Use Case If you want to run multiple tasks and you don’t need to wait for the previous method, then you have to run the asynchronous function in parallel. In this post, I will show you how to execute asynchronous tasks in parallel by using callbacks, promises, and Async/Await.We will have three asynchronous functions. I’m […]

0 Shares

Execute Asynchronous Tasks in Series

October 10, 2017

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 […]