Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Aifert committed Mar 13, 2024
1 parent 3faa6e4 commit 789ed01
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/pages/donations-success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ export default function DonationSuccess() {
const response = await fetch(
`/api/getSession?session_id=${sessionIdFromURL}`
);
const sessionData = await response.json();

if (sessionData) {
if (sessionData.session.amount_total == amountInCentsfromURL) {
const formatted_amount = parseInt(amountInCentsfromURL) / 100;
if(response.ok){
const sessionData = await response.json();

setAmount(formatted_amount);
}
if (sessionData) {
if (sessionData.session.amount_total == amountInCentsfromURL) {
const formatted_amount = parseInt(amountInCentsfromURL) / 100;

setAmount(formatted_amount);
}
}
}
else{
setAmount(-1);
}
}
};
Expand Down

0 comments on commit 789ed01

Please sign in to comment.