Post(s) tagged Async

Best and easy way to use Async parallel in Node Js

Using the below method can get the results for each task very easily

async.parallel({
    firstTask: function (callback) {
        callback(null, 'fist task result');
    },
    secondTask: function (callback) {
        callback(null, 'second task result');
    }
}, function (err, results) {
    // results now equals to: results.firstTask: 'fist task result', results.secondTask: 'second task result'
});


71 Views Posted on February 10, 2022

How to use Async Await inside react useEffect() hook

The following method is a safe way to use await and async inside react useEffect() hook

const getUsers = async () => {
    const users = await fetchUsers();
    setUsers(users);
};

useEffect(() => {
  getUsers(); // run it, run it

  return () => {
    // this now gets called when the component unmounts
  };
}, []);


9 Views Posted on February 19, 2022
SPONSORS