✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Code A:
fetch('https://api.example.com/data')
.then(response => {
if (!response.ok) {
throw new Error('Netzwerkantwort war nicht ok');
}
return response.
json();
})
.then(data => {
console.log(data);
})
.catch(error => {
console.error('Fehler:', error);
});
Code B:
fetch('https://api.example.com/data')
.then(data => {
console.log(data);
})
.catch(error => {
console.error('Fehler:', error);
});