-
Notifications
You must be signed in to change notification settings - Fork 881
Open
Description
Hello sir @SuperSimpleDev @spencer-lochne
I noticed that the code redirects to orders.html even if the fetch request fails.
This happens because window.location.href = 'orders.html'; is outside the try...catch, so it runs no matter what.
Maybe you could move the redirect inside the try block, so it only happens if the fetch is successful?
Example:
try {
const response = await fetch(...);
const order = await response.json();
addOrder(order);
window.location.href = 'orders.html'; // redirect after success
} catch (error) {
console.log('Unexpected error. Try again later.');
}
Just a small thing I noticed. Thanks for the cool project! @SuperSimpleDev
Metadata
Metadata
Assignees
Labels
No labels