Add to Chrome
✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Welche der folgenden Codebeispiele verwendet die Fetch-API korrekt, um Daten von einer URL abzurufen?
fetch('https://api.example.com/data') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
)
.then(
())
.log(data))
.catch(
fetch('https://api.example.com/data') .then(response => { if (!response.ok) { console.error('Network response was not ok'); } return response.json(); }) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
{
(!response.ok) {
);
}
();
})
fetch('https://api.example.com/data') .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { console.log(data); }) .catch(error => { console.error('There has been a problem with your fetch operation:', error); });
.log(data);
, error);
});
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!