Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Open
SmartSankarCode wants to merge 1 commit intoSuperSimpleDev:mainSuperSimpleDev/javascript-course:mainfrom
SmartSankarCode:fixing-bugSmartSankarCode/javascript-course:fixing-bugCopy head branch name to clipboard
Open

Bug: Redirect happens even when fetch fails in paymentSummary.js#163
SmartSankarCode wants to merge 1 commit intoSuperSimpleDev:mainSuperSimpleDev/javascript-course:mainfrom
SmartSankarCode:fixing-bugSmartSankarCode/javascript-course:fixing-bugCopy head branch name to clipboard

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.