diff --git a/framework/ordercloud/api/endpoints/checkout/get-checkout.ts b/framework/ordercloud/api/endpoints/checkout/get-checkout.ts index d5a1cd5ec..6cef3d4c1 100644 --- a/framework/ordercloud/api/endpoints/checkout/get-checkout.ts +++ b/framework/ordercloud/api/endpoints/checkout/get-checkout.ts @@ -13,39 +13,24 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({ }) } - try { - // Register credit card - const payments = await restFetch( - 'GET', - `/orders/Outgoing/${cartId}/payments` - ).then((response: { Items: unknown[] }) => response.Items) + // Register credit card + const payments = await restFetch( + 'GET', + `/orders/Outgoing/${cartId}/payments` + ).then((response: { Items: unknown[] }) => response.Items) - const address = await restFetch('GET', `/orders/Outgoing/${cartId}`).then( - (response: { ShippingAddressID: string }) => response.ShippingAddressID - ) + const address = await restFetch('GET', `/orders/Outgoing/${cartId}`).then( + (response: { ShippingAddressID: string }) => response.ShippingAddressID + ) - // Return cart and errors - res.status(200).json({ - data: { - hasPayment: payments.length > 0, - hasShipping: Boolean(address), - }, - errors: [], - }) - } catch (error: any) { - console.log(error, error.toString(), JSON.stringify(error)) - - // Return cart and errors - res.status(500).json({ - data: null, - errors: [ - { - message: error.message, - code: error.statusCode || error.code || error.status, - }, - ], - }) - } + // Return cart and errors + res.status(200).json({ + data: { + hasPayment: payments.length > 0, + hasShipping: Boolean(address), + }, + errors: [], + }) } export default getCheckout diff --git a/framework/ordercloud/api/utils/fetch-rest.ts b/framework/ordercloud/api/utils/fetch-rest.ts index f355174e9..ecd63715a 100644 --- a/framework/ordercloud/api/utils/fetch-rest.ts +++ b/framework/ordercloud/api/utils/fetch-rest.ts @@ -95,12 +95,12 @@ export async function fetchData( } // Get the body of it - const error = await dataResponse.json() + const error = await dataResponse.textConverted() // And return an error throw new FetcherError({ - errors: [{ message: error.error_description.Code }], - status: error.error_description.HttpStatus, + errors: [{ message: error || dataResponse.statusText }], + status: dataResponse.status, }) }