Skip to content

Bug: Redirect happens even when fetch fails in paymentSummary.js #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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