Updated cancelation URL for donations (#17555)

refs https://github.com/TryGhost/Product/issues/3650
- also adds an await on the .json() call
This commit is contained in:
Sag 2023-08-01 17:19:15 +02:00 committed by GitHub
parent 6d85ea4425
commit 4e0f52a7cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -15,7 +15,7 @@ const SupportPage = () => {
const siteUrl = window.location.origin;
const currentUrl = siteUrl + window.location.pathname;
const successUrl = `${currentUrl}#/portal/support/success`;
const cancelUrl = `${currentUrl}#/portal/support/error`;
const cancelUrl = currentUrl;
const api = setupGhostApi({siteUrl});
try {

View File

@ -424,14 +424,14 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
body: JSON.stringify(body)
});
if (!response.ok) {
const errorData = await response.json();
const errorMessage = errorData?.errors?.[0]?.message || 'There was an error processing your payment. Please try again.';
const responseJson = await response.json();
if (!response.ok) {
const errorMessage = responseJson?.errors?.[0]?.message || 'There was an error processing your payment. Please try again.';
throw new Error(errorMessage);
}
return response.json();
return responseJson;
},
async editBilling({successUrl, cancelUrl, subscriptionId} = {}) {