What are Promises and async/await in Node.js? How do they differ from callbacks?

Promises represent the eventual completion (or failure) of an asynchronous operation and its resulting value, while async/await is syntactic sugar for working with Promises, allowing asynchronous code to be written in a more synchronous manner. They help avoid callback hell and improve readability. Example using async/await:

const fetchData = async () => {
  try {
    const response = await fetch('https://api.example.com/data');
    const data = await response.json();
    console.log(data);
  } catch (error) {
    console.error('Error fetching data:', error);
  }
};

fetchData();