Log checkout error

This commit is contained in:
goncy
2021-09-29 11:03:05 -03:00
parent 243d18d18e
commit 4b710bf850

View File

@@ -13,10 +13,12 @@ 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
)
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
@@ -26,10 +28,24 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
res.status(200).json({
data: {
hasPayment: payments.length > 0,
hasShipping: Boolean(address)
hasShipping: Boolean(address),
},
errors: []
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,
},
],
})
}
}
export default getCheckout