4
0
forked from crowetic/commerce

Fixed type

This commit is contained in:
Luis Alvarez
2020-10-21 15:21:31 -05:00
parent 1569d62902
commit 316801627b
3 changed files with 49 additions and 36 deletions

View File

@@ -20,40 +20,40 @@ const signup: SignupHandlers['signup'] = async ({
let result: { data?: any } = {}
try {
result = await config.storeApiFetch('/v3/customers', {
method: 'POST',
body: JSON.stringify([
{
first_name: firstName,
last_name: lastName,
email,
authentication: {
new_password: password,
},
},
]),
})
} catch (error) {
if (error instanceof BigcommerceApiError && error.status === 422) {
const hasEmailError = '0.email' in error.data?.errors
// try {
// result = await config.storeApiFetch('/v3/customers', {
// method: 'POST',
// body: JSON.stringify([
// {
// first_name: firstName,
// last_name: lastName,
// email,
// authentication: {
// new_password: password,
// },
// },
// ]),
// })
// } catch (error) {
// if (error instanceof BigcommerceApiError && error.status === 422) {
// const hasEmailError = '0.email' in error.data?.errors
// If there's an error with the email, it most likely means it's duplicated
if (hasEmailError) {
return res.status(400).json({
data: null,
errors: [
{
message: 'The email is already in use',
code: 'duplicated_email',
},
],
})
}
}
// // If there's an error with the email, it most likely means it's duplicated
// if (hasEmailError) {
// return res.status(400).json({
// data: null,
// errors: [
// {
// message: 'The email is already in use',
// code: 'duplicated_email',
// },
// ],
// })
// }
// }
throw error
}
// throw error
// }
console.log('DATA', result.data)