این کد را ببین:
fetch('/api/users')
.then(res => res.json())
.then(data => {
throw new Error('Oops!');
});اگر
catch نداشته باشی:❌ خطا ممکن است نادیده گرفته شود.
❌ دیباگ سختتر میشود.
راه بهتر:
fetch('/api/users')
.then(res => res.json())
.then(data => {
throw new Error('Oops!');
})
.catch(err => {
console.error(err);
});💡 خطاهایی که مدیریت نمیشوند، معمولاً در Production خودشان را نشان میدهند.
#JavaScript #Frontend #Debugging
@CodeVerse_dev