mirror of
https://github.com/vercel/commerce.git
synced 2025-03-15 06:52:32 +00:00
Fixed type
This commit is contained in:
parent
1569d62902
commit
316801627b
@ -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)
|
||||
|
||||
|
@ -20,6 +20,8 @@ export default async function fetchGraphqlApi<Q, V = any>(
|
||||
}),
|
||||
})
|
||||
|
||||
// console.log('HEADERS', getRawHeaders(res))
|
||||
|
||||
const json = await res.json()
|
||||
if (json.errors) {
|
||||
console.error(json.errors)
|
||||
@ -27,3 +29,13 @@ export default async function fetchGraphqlApi<Q, V = any>(
|
||||
}
|
||||
return json.data
|
||||
}
|
||||
|
||||
function getRawHeaders(res: Response) {
|
||||
const headers: { [key: string]: string } = {}
|
||||
|
||||
res.headers.forEach((value, key) => {
|
||||
headers[key] = value
|
||||
})
|
||||
|
||||
return headers
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { BigcommerceApiError } from '../../utils/errors'
|
||||
import type { WishlistList, WishlistHandlers } from '..'
|
||||
import type { Wishlist, WishlistHandlers } from '..'
|
||||
|
||||
// Return all wishlists
|
||||
const getAllWishlists: WishlistHandlers['getAllWishlists'] = async ({
|
||||
@ -7,10 +6,12 @@ const getAllWishlists: WishlistHandlers['getAllWishlists'] = async ({
|
||||
body: { customerId },
|
||||
config,
|
||||
}) => {
|
||||
let result: { data?: WishlistList } = {}
|
||||
let result: { data?: Wishlist[] } = {}
|
||||
|
||||
try {
|
||||
result = await config.storeApiFetch(`/v3/wishlists/customer_id=${customerId}`)
|
||||
result = await config.storeApiFetch(
|
||||
`/v3/wishlists/customer_id=${customerId}`
|
||||
)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user