NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 12

What is promises chaining in node Js

Promises can be chained using the then() method, allowing you to perform multiple asynchronous operations sequentially.

Here's is the Code !!

const fetchData = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve('Data fetched successfully!');
    }, 2000);
  });
};

fetchData()
  .then((data) => {
    console.log(data); // Output: "Data fetched successfully!"
    return 'Processed data';
  })
  .then((processedData) => {
    console.log(processedData); // Output: "Processed data"
  })
  .catch((error) => {
    console.error(error);
  });

Chapter 11

What is promises in node js

Previous chapter

Chapter 13

What is the concept of Async/Await in node Js

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex