Skip to content

Conversation

@SmartSankarCode
Copy link

@SmartSankarCode SmartSankarCode commented Apr 27, 2025

Hey! @SuperSimpleDev

I noticed that the app 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

@SmartSankarCode SmartSankarCode changed the title Redirect happens even when fetch fails in paymentSummary.js Bug: Redirect happens even when fetch fails in paymentSummary.js Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant