mirror of
https://github.com/vercel/commerce.git
synced 2025-09-07 16:30:17 +00:00
Added login operation
This commit is contained in:
@@ -17,8 +17,10 @@ const createCustomer: CustomersHandlers['createCustomer'] = async ({
|
||||
// Passwords must be at least 7 characters and contain both alphabetic
|
||||
// and numeric characters.
|
||||
|
||||
let result: { data?: any } = {}
|
||||
|
||||
try {
|
||||
const { data } = await config.storeApiFetch('/v3/customers', {
|
||||
result = await config.storeApiFetch('/v3/customers', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify([
|
||||
{
|
||||
@@ -31,8 +33,6 @@ const createCustomer: CustomersHandlers['createCustomer'] = async ({
|
||||
},
|
||||
]),
|
||||
})
|
||||
|
||||
res.status(200).json({ data })
|
||||
} catch (error) {
|
||||
if (error instanceof BigcommerceApiError && error.status === 422) {
|
||||
const hasEmailError = '0.email' in error.data?.errors
|
||||
@@ -53,6 +53,8 @@ const createCustomer: CustomersHandlers['createCustomer'] = async ({
|
||||
|
||||
throw error
|
||||
}
|
||||
|
||||
res.status(200).json({ data: result.data ?? null })
|
||||
}
|
||||
|
||||
export default createCustomer
|
||||
|
Reference in New Issue
Block a user