Kizspy | Question: 44
(Choose 2 answers)
Consider the following code snippet using async/await:
async function fetchData() {
try{
let response = await fetch('
https://api.example.com/data');
let data = await response.json();
console.log(data);
catch (error)
console.error('Error:', error);
fetchData();
What are the advantages of using async/await in this code?
A. It makes the code easier to read and understand.
B. It ensures the code runs synchronously.
C. It simplifies error handling with try/catch blocks.
D. It eliminates the need for callbacks entirely.