The biggest mistake in Ajax is not catching ‘Silent Failures’ like a 404 or 500 status code.
async function fetchData(url) {
try {
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP Error: ${response.status}`);
return await response.json();
} catch (error) {
console.error("Safety Net caught this:", error);
}
}
